• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Want Help Reagarding Reading Text

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers
Hope all are fine.
Here is a one tricky Q.
Iam using the following code
to read the contents from a file.
*********************************************
FileOutputStream fos1 = new FileOutputStream(file);
for(long i=0;i<filelength;i++)
{
int b = fis1.read();
}
*******************************************
Question is,
After reading using read() method.......i want to print to console that particular character the Byte contains.How to do that..???

Regards
Khad M
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you want to read from an Output stream?
 
khad M
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Barry Gaunt:
Why do you want to read from an Output stream?



B'cas i ant to compare that character contained by the Byte with my own defined character.???
Is it sounds good..!!!
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But FileOutputStream does not have a read method.
The API states:

A file output stream is an output stream for writing data to a File or to a FileDescriptor.


Is your FileOutputStream actually connected to a file?
If it is you, you could use a FileInputStream to read it back in.
The code you have provided does not look correct.
You could read your byte into a single element byte
array, then construct a String object using whatever coding scheme you require, and print the resulting single character string.
[ November 08, 2002: Message edited by: Barry Gaunt ]
 
After some pecan pie, you might want to cleanse your palatte with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic