Win a copy of The Java Performance Companion this week in the Performance forum!
    Bookmark Topic Watch Topic
  • New Topic

file io

 
mike hengst
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Report post to moderator
I am having a problem figuring exactly what I need to do on this problem. I want to read in a file, place it in an array. After that it needs to be sent to a class that calculates the charge. The second part is supposed to output the results to another file(txt). I think I have the first part down. What I am wondering is how does one instantiate an object array, place the results into the appropiate array and then take that and print to a text file???Here is the code I have so far, any help will keep me from freakin' out...

[ December 14, 2002: Message edited by: mike hengst ]
 
Viet Nguyen
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
I think you need a Printwriter in the try and catch block to print the results to the .txt files
for Example
{
try{
PrintWriter out = new PrintWriter(new FileWriter(outFile.txt));
All you codes goes here.
}catch(IOException e)
{
}
out.flush();
out.close();
System.out.println("finished");
}
 
mike hengst
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks,Viet
I have been working on this all afternoon and I have changed my code to inlcude the PrintWriter stuff. i just don't think I am doing it right. Here is my ammended code. Maybe you or someone else can see what I am doing wrong, or not doing at all.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Report post to moderator
Continued here.
 
    Bookmark Topic Watch Topic
  • New Topic