Help coderanch get a
new server
by contributing to the fundraiser
  • 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

help with code!

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
**THis is a code I got from Rahul
HOw do i alter this code so that it can read a string or a double ?? Here it can only read either character and i've tried integer type and it works too. Thx
import java.io.*;
class demo{
public static void main(String args[]){
try{
FileOutputStream in=new FileOutputStream("Rahul");
in.write('r');
in.close();
}
catch(Exception e){
System.out.println(e);
}//end of catch
try{
FileInputStream in=new FileInputStream("Rahul");
int i=0;
while((i=in.read())!=-1){
System.out.println((char)i);
}//end of while
}//end of try
catch(Exception e){
System.out.println(e);
}//end of catch
}//end main
}//end class
 
Get out of my mind! Look! A tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic