• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

datainputStream output is not showing clear on notepad

 
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
 
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at XMLEncoder.
 
Greenhorn
Posts: 24
Eclipse IDE Chrome 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?
 
Marshal
Posts: 69820
278
  • 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: 69820
278
  • 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.
    Bookmark Topic Watch Topic
  • New Topic