I am trying to read a text file that contains English words and their meaning in another [sinhala] language, divided by an equal mark and broken into "|", a mark. It looks like this:
abmodality=අපමාතිය
abnegate=අයිතිවාසිකම අත්හරිනවා | ත්යජනය කරනවා | පිළිගැනීම අත්හරිනවා | මතය අත්හරිනවා
abnormal=අනියම් | අපසාමාන්ය | අප්රමත | අවප්රමාණ | අස්වාභාවික | අසාමාන්ය | පුදුම
abnormalism=අසාමාන්යභාවය
abnormality=අනියම් බව | අප්රමතිය | අසාමාන්යත්වය | අසාමාන්යය | විපරීතය | විශේෂය
abnormally=අනියම් ලෙසින් | අසාමාන්ය ලෙස | රියකට ගොඩ වී | විපරීතව
aboard=දුම්රියේ | නැවේ | යාත්රාවකට ගොඩ වී | යාත්රාවේ | වාහනයක
this is actually a dictionary, and it contains all the English words pointing to z.I'm going to create a MySQL db using this file because I cannot insert all the words and meanings manually because it is too big.
therefore, I created a java program that creates a MySQL program query, so I can easily insert 1 to many into my database, which has 2 tables. In fact, my problem is the program giving me an error, and I found which line of the text file gives this error, read.important and the confusing fact is not a unique line if I run my program 5 times when an error occurred while reading different lines .
this is my code
String[] parts ;
String en;
String[] sin;
try {
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\Users\\Madhawa.se\\Desktop\\bac\\gui\\lktips-v3-lionlk.com\\a.txt"), "UTF-8"));
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
String s = br.readLine();
parts = s.split("=");
en=parts[0];
sin=parts[1].split(" | ");
sb.append("INSERT INTO `singlish`.`eng` (`eid`, `eword`) VALUES ('"+stpoint+"', '"+en+"');")
sb.append(System.lineSeparator());
System.out.println(en);
for(int i=0;i<sin.length;i++){
sb.append("INSERT INTO `singlish`.`sng` (`eid`, `sword`) VALUES ('"+stpoint+"', '"+sin[i]+"');");
sb.append(System.lineSeparator());
}
System.out.println(""+stpoint);
stpoint++;
}
System.out.println("finished"+subs.size());
String everything = sb.toString();
jTextArea1.append(everything);
br.close();
} catch (Exception ex) {
ex.printStackTrace();
}
however, this is the result and the error I received, but the change in the result every time I run
attention
3742
attentive
3743
attentively
3744
java.lang.NullPointerException
at subtitleseeker.NewJFrame.jButton3ActionPerformed(NewJFrame.java:180)
at subtitleseeker.NewJFrame.access$200(NewJFrame.java:17)
at subtitleseeker.NewJFrame$3.actionPerformed(NewJFrame.java:60)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
attentiveness
3745
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
attenuant
source
share