• Post Reply Bookmark Topic Watch Topic
  • New Topic

datainputStream output is not showing clear on notepad  RSS feed

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I have following code



it writes data on output file and i get soething like

 Dehradun@ff@ ûçl‹C–


But when i again view it using datainputstream it display original Values.

My Question is how to view correct data written from outputstream as it is in textpad file


Thanks
 
Knute Snortum
Sheriff
Posts: 4270
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at XMLEncoder.
 
David McMonigle
Greenhorn
Posts: 24
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try using Buffered Readers and Writers. They work spectacularly when trying to write to text files. If you're just trying to store the data, check out This Tutorial. I love this guy.

That tutorial is also a great way to save data for classes using mkyong's file input tutorial. I use that to save a bunch of stuff.

Pretty much what happened was your FileInputStream gave you an array Bytes. You have to convert those bytes back to characters by casting the bytes as chars
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read the
http://docs.oracle.com/javase/7/docs/api/java/beans/XMLEncoder.html

but its a class that is used for XML reading stream.

But in my case it is not XmL its a format compatiablity issues

any other suggestions?
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That tutorial is pretty poor. you should not use an input stream for a text file. You should use a reader, or better a Scanner. Start with the Java Tutorials.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes

That problem is solved

I used PrintStream class for formatted text to output stream and it work
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done sorting it out
Yes, I think a print stream will work well.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!