• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we write in a file from an array???

 
Vishnu Sharma
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The end user is entering the data on console and i am storing it in a two dimensional String array of 10X10. I am using BufferedStreamWriter to pick one line from the array and write in a text file. But i am not getting the output in file.
For loop is being used for writing from array to the text file.
Please tell me the mistake, i am doing.....
 
Manish Chhabra
Greenhorn
Posts: 15
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vishnu,

It would be easier to identify the problem if you share some code.

By the way are you flushing out and closing the data stream before your program finishes?

Check out flush( ) method in BufferedWriter (I am guessing you are using BufferedWriter, there is no such class "BufferedStreamWriter" in java io).

Cheers,
Manish
 
Vishnu Sharma
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manish Chhabra wrote:Hi Vishnu,

It would be easier to identify the problem if you share some code.

By the way are you flushing out and closing the data stream before your program finishes?

Check out flush( ) method in BufferedWriter (I am guessing you are using BufferedWriter, there is no such class "BufferedStreamWriter" in java io).

Cheers,
Manish


Hi, PFB the code:

 
Gopi Chella
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can use BufferdWritter like Below

 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishnu: Please UseCodeTags when you post source code.
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishnu, please UseOneThreadPerQuestion. This thread is identical to this one. Since this thread has more replies we'll continue here.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using a stream writer rather than an ordinary BufferedWriter?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic