FileInputStream example in Java
import
java.io.FileInputStream;
import
java.io.FileNotFoundException;
import
java.io.IOException;
import
java.io.InputStream;
public
class
FileInputStreamDemo {
public
static
void
main( String [] args ){
try
{
InputStream inputStream =
new
FileInputStream("C:\\outFile.txt");
int
size =inputStream.available();//determine
the size of the file
//inputstream
available method throws IOException
System. out.println("SIZE
OF THE FILE:"+ size);
String word;
for(
int
i=0;i<size;i++){
System. out.print((char)inputStream.read());
//
}
}
catch
(FileNotFoundException e) {
//
TODO
Auto-generated catch block
e.printStackTrace();
}
catch
(IOException e) {
//
TODO
Auto-generated catch block
e.printStackTrace();
}
}
}
//output : The file input we
gave is the out put of
Fileoutputstream example
Please send comments to vgdarur.javafive@blogger.com
|