Reply to comment
Opening / Displaying Content of Text File in java
Tagged:
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class OpenFile {
public static void main(String[] args) throws IOException {
String path = "/home/jr/Desktop/file1.txt";
File file = new File(path);
DataInputStream dis = new DataInputStream( new BufferedInputStream( new FileInputStream(file) ) );
if( file.exists() )
while (dis.available() != 0)
System.out.println(dis.readLine());
else
System.out.println(" file does not exist");
dis.close();
}
}



Recent comments
1 week 2 days ago
1 week 5 days ago
2 weeks 1 day ago
2 weeks 3 days ago
3 weeks 1 day ago
4 weeks 3 days ago
4 weeks 6 days ago
5 weeks 4 days ago
9 weeks 1 day ago
15 weeks 1 day ago