When i run my java code:
public class LalaLuLu {
public static void main(String[] args) {
try{
String path = "D:/Gem/FINAL/Datatest.csv";
File file = new File(path);
InputStream is;
System.out.println(file.exists());
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
PrintWriter os = new PrintWriter ( new FileOutputStream("D:/Gem/FINAL/out_datatest1.txt"));
String output = "";
int count = 0;
do{
output = br.readLine();
String[] a = output.split(";");
System.out.println("total kolom: " + a.length);
os.println(output);
System.out.println(count++ );
} while (!output.equals(""));
} catch (Exception e) {
e.printStackTrace();
}
} }
When i run, the error on this line :
output = br.readLine();
String[] a = output.split(";");
And error I am getting is:
java.lang.NullPointerException
at DAO.readdata.readdataCSV(readdata.java:47)
Can you tell me how to solve this error? Thank you