I have an input of
-157,118
-170,12
-74,139
-144,42
-155,196
122,-88
-187,-143
156,-18
-67,126
44,-102
....
這樣.I必須檢查在一個文件中的每個數(其中i有更多的輸入,比如這些)和必須找到哪一對屬於(+ VE,霧化+ ve ).plese任何人幫助我。我是能夠從文件中讀取。我已經做了這個數字..如何使在Java正數的座標
public class EulerGift {
public static void main(String[] args) {
// List<String> coordinateList=new ArrayList<String>();
File file = new File("D:/coordinate.txt");
try {
Scanner sc = new Scanner(file);
while (sc.hasNext()) {
String value = sc.next();
String[] tokens = value.split(",");
for (int i = 0; i < tokens.length; i++) {
System.out.println("("+Integer.parseInt(tokens[i])+")");
// System.out.println(Integer.parseInt(tokens[i]));
}
}
} catch (FileNotFoundException e) {
System.err.format("File Not Found");
}
}
}
我們展示的代碼你在哪裏閱讀文件中的數字...你只能在那裏檢查它是否是數字。 –
我在編輯我的帖子 – Mandrek
你需要澄清你的問題。什麼是+ ve?我假設這是作業。你問如何打開一個文件?或者如何比較兩個值?從詢問問題的方式來看,它可能也是。 – spuder