File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 13869
    
  10

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: 19541
    
  16

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: 36478
    
  16
Why are you using a stream writer rather than an ordinary BufferedWriter?
 
I agree. Here's the link: http://aspose.com/file-tools
 
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?
JDBC for loading data into SQL Server
how to write and read excel file
writing into a text file