• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.....
 
Greenhorn
Posts: 15
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you can use BufferdWritter like Below

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vishnu: Please UseCodeTags when you post source code.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you using a stream writer rather than an ordinary BufferedWriter?
 
I found some pretty shells, some sea glass and this lovely tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic