我想寫一個代碼從txt文件中選擇功能。 即大小= 1.4356474
種類= FW,WEVB,WRG,GWE ....Java程序繼續運行,沒有編譯器的錯誤
這是我寫到目前爲止代碼:
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.text.ParseException;
import java.util.concurrent.ExecutionException;
public class Metodi {
public static void main (String[] args) {
String volume = findVolume();
System.out.println(volume);
}
public static String readSpecification() {
String spec = "";
// trying to read from file the specification...
try {
BufferedReader reader = new BufferedReader(new FileReader("Gemcitabine.txt"));
String line = reader.readLine();
while(line!=null) {
spec += line + "\n";
line = reader.readLine();
}
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
return spec;
}
public static String findVolume() {
String res = "";
String vol = "volume";
try {
BufferedReader reader1 = new BufferedReader(new FileReader("Sample.txt"));
String line1 = reader1.readLine();
while(line1!=null) {
if(line1.toLowerCase().indexOf(vol) != -1) {
String[] str = line1.split("=");
res = str[1].split(" ")[0];
}
}
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
return res;
}
}
它不給我任何編譯器的錯誤,但是當我啓動它時,它會繼續運行並且不會結束。 有什麼幫助嗎?
的可能的複製[什麼是調試器以及它如何幫助我診斷問題] (http://stackoverflow.com/questions/25385173/what-is-a-debugger-and-how-can-it-help-me-diagnose-problems) – Raedwald