wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes Skipping input and writing to file using FileWriter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Skipping input and writing to file using FileWriter" Watch "Skipping input and writing to file using FileWriter" New topic
Author

Skipping input and writing to file using FileWriter

montag constantine
Greenhorn

Joined: Jun 14, 2011
Posts: 4
I have a question. This is my first commercial application and I'm having some issues printing four 96 well plates to a text file because I have to point the input stream to the top of the page and ignore the first 41st characters on the same line in order to print plate C. What I'm trying to do will be immediately clear if you see the attachment. I'm processing data from the first plates A and B but having to write B to the right of A and D to the right of C. How would I go about doing this? Eclipse is claiming mark and reset aren't supported by FileWriter, FileReader, etc. I know I could create a temp text file with a and b etc and c and d etc and then merge the two but that doesn't seem like the most efficient/safe option. Plates can go up to Z and AA and etc.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

I would read in the data and build a page in memory, then write the whole page to the FileWriter. You can put the data into memory in any order you like.
montag constantine
Greenhorn

Joined: Jun 14, 2011
Posts: 4
How would you recommend building it into memory? I was thinking maybe like a string object, like an array of strings I guess? Better idea? I know that the number of lines will always be fixed per plate/page, etc.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18991
    
    8

An array of strings, one array entry per printed line seems like a good start to me.
montag constantine
Greenhorn

Joined: Jun 14, 2011
Posts: 4
Excellent. Thanks very much Paul. I'll report back and let you know if I have trouble/luck.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Skipping input and writing to file using FileWriter