• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic