Twitter Update

Using Fileinputstream in java programming [JAVA]

This Fileinputstream is read data in file and will output in program with read(). here I use notepad,First we create program in notepad, we type whatever, and save, you must don't forget the location, because it use in program. This is the code :


package fileinputstream;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        File a= new File("File.txt");
        FileInputStream f=new FileInputStream(a);
        int b;
        do
        {
            b=(int)f.read();
        System.out.print((char)b);
        }while(b!=-1);
   f.close();
    }
}

file.txt is only example, you can change by yourself

0 comments:

Post a Comment

ABOUT ME

IP
Albert Julius. Powered by Blogger.
Copyright © Albert'Blog