Home
> Java > Java Program to read data from a file through inputfilestream and show it on the console. – Q34
Java Program to read data from a file through inputfilestream and show it on the console. – Q34
Q34: Java Program to read data from a file through inputfilestream and show it on the console.
import java.io.*;
import javax.swing.*;
class File_read{
public static void main(String args[]) throws IOException{
String f_name = JOptionPane.showInputDialog("Enter a File name: ");
File f = new File(f_name);
InputStream file = new FileInputStream(f);
int fsize = file.available();
System.out.println("Reading File : " + f.getName() + "\n");
for(int i=0; i<fsize; i++)
System.out.print((char)file.read());
}
}
… from College notes (BCA/MCA assignments):
Categories: Java
Java File Handling, Java IO Programs
Comments (0)
Trackbacks (0)
Leave a comment
Trackback




