我遇到任務問題。多任務:從字符串中解析空格分隔的整數
我的工作是
- 抓鬥從文件中
String
(在源文件是數字在一行中,由空間劃分) - 分裂由空格該字符串
- 然後分析每個
String
到int
- 最後在它們上面使用bubbleSort。
我被解析了,不知道該怎麼做。
代碼ATM看上去某事像這樣:
public class Main
{
public static void main(String[] args) throws IOException
{
String numbers = new String(Files.readAllBytes(Paths.get("C:\\README.txt")));
String s[] = numbers.split(" ");
for (String element : s)
{
System.out.println(element);
}
}
}
我試圖用掃描儀讀取串號,然後循環它parseInt函數,但對我不起作用。
你有沒有試圖parseInt得到任何錯誤?請詳細說明你的問題:) – Frunk 2014-10-31 08:31:33