Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Skipping input and writing to file using FileWriter

 
montag constantine
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 20711
29
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 20711
29
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An array of strings, one array entry per printed line seems like a good start to me.
 
montag constantine
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excellent. Thanks very much Paul. I'll report back and let you know if I have trouble/luck.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic