我遇到任务问题。多任务:从字符串中解析空格分隔的整数
我的工作是
- 抓斗从文件中
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