The variable lastTagPair always equal null. The editor is utf-8, the file reader is also utf-8, obviously the if statement is satisfied, but the code in if statement was never executed.
public static HashMap<String, String> fileRead(){
HashMap<String, String> dummy_tagPairSentences = new HashMap<String, String>();
try {
String encoding="UTF-8";
File file=new File("entityLinkiingResult3.txt");
if(file.isFile() && file.exists()){ //
InputStreamReader read = new InputStreamReader(
new FileInputStream(file),encoding);//
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt = null;
String lastTagPair = null;
String candidateSentences = null;
String dummy_title = null;
String tagPair = null;
while((lineTxt = bufferedReader.readLine()) != null){
if (lineTxt.length() >= 8){
dummy_title = lineTxt.substring(0,7);
tagPair = lineTxt.substring(8);
//System.out.println(dummy_title + " " + tagPair);
}
else{
}
if (dummy_title == "TagPair"){
dummy_tagPairSentences.put(lastTagPair,candidateSentences);
System.out.println(lastTagPair + candidateSentences);
System.out.println("?");
lastTagPair = tagPair;
candidateSentences = null;
}
else
{
candidateSentences += lineTxt + "\n";
}
}
read.close();
}else{
System.out.println;
}
} catch (Exception e) {
System.out.println;
e.printStackTrace();
}
return dummy_tagPairSentences;
}
Aucun commentaire:
Enregistrer un commentaire