This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Can we write in a file from an array??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can we write in a file from an array???" Watch "Can we write in a file from an array???" New topic
Author

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

Vishnu Sharma
Ranch Hand

Joined: Feb 03, 2010
Posts: 55
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.....


Regards,
Vishnu
Manish Chhabra
Greenhorn

Joined: Feb 24, 2010
Posts: 15

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


Manish Chhabra
Vishnu Sharma
Ranch Hand

Joined: Feb 03, 2010
Posts: 55
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

Joined: Apr 26, 2010
Posts: 53
Yes you can use BufferdWritter like Below



SCJP 1.5
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Vishnu: Please UseCodeTags when you post source code.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Vishnu, please UseOneThreadPerQuestion. This thread is identical to this one. Since this thread has more replies we'll continue here.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37937
    
  22
Why are you using a stream writer rather than an ordinary BufferedWriter?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can we write in a file from an array???
 
Similar Threads
HTTP receiving problems with non text files.
Can we write in a file from an array?
writing into a text file
JDBC for loading data into SQL Server
how to write and read excel file