Following is an example how to read the file and display using System.out.println()
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class FileReader {
public static void main(String[] args) {
String file = "C:\\Users\\test.csv";
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(
new FileInputStream(file)));
while (reader.readLine() != null) {
System.out.println(reader.readLine());
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
No comments:
Post a Comment