-
io.problem
hi,
im new in computing....that's why i think java programming is too difficult
to me....
recently, i've been trying to convert one data file to another formated file...
the contents of the file data1.dat is in the following:
01, 647394,06/03/01,0748,0,06/03/2001
01, 642924,06/03/01,0748,0,06/03/2001
01, 642924,06/03/01,0748,0,06/03/2001
-------------
i would like to convert the data of the above file to another formated file
data2.dat and the contents looks like:
"001:647394:010306:074800"
"001:642924:010306:074800"
"001:642924:010306:074800"
do u know how to solve the above problem, please help
thanks
leo
here is my source code...that's what i have done so far:
import java.awt.*;
import java.io.*;
public class StreamTokenizerTest extends Frame {
public static void main(String args[]) {
StreamTokenizerTest test=new StreamTokenizerTest();
TextArea ta=new TextArea();
try {
StreamTokenizer stoken=new StreamTokenizer(new FileReader ("trans.dat"));
stoken.eolIsSignificant(true);
stoken.parseNumbers();
stoken.quoteChar('\"');
stoken.slashSlashComments(true);
stoken.slashStarComments(true);
while (true) {
stoken.nextToken();
if (stoken.ttype==StreamTokenizer.TT_EOF)
break;
else if (stoken.ttype==StreamTokenizer.TT_EOL)
ta.append("sss" + stoken.lineno()+"line\n");
else if (stoken.ttype==StreamTokenizer.TT_NUMBER)
ta.append("Number:"+stoken.nval+":");
else if (stoken.ttype==StreamTokenizer.TT_WORD)
ta.append("String:"+stoken.sval+"\n");
else if (stoken.sval!=null)
ta.append("other:"+stoken.sval+"\n");
}
}
catch (FileNotFoundException e) {
System.out.println("File not Found.");
System.exit(0);
}
catch (IOException e) {
System.out.println("IOException");
}
test.add(ta,BorderLayout.CENTER);
test.setSize(300,300);
test.setVisible(true);
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks