• Post Reply Bookmark Topic Watch Topic
  • New Topic

help with code!

 
Tersa
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!