【发布时间】:2014-04-21 22:15:54
【问题描述】:
我是一名新程序员,我对这段代码有疑问。
public static String getString() throws IOException {
String content = null;
File folder = new File("C:\\Soluzioni.txt");
content = FileUtils.readFileToString(folder) + "\n";
String remainingString = content.substring(content.indexOf("["),
content.lastIndexOf("]") + 1);
System.out.println(remainingString); // Output 1.
return remainingString;
}
当我使用这个方法时
public static String[] arg() throws IOException {
String[] strArray = getString().split("\\s+,0");
System.out.println(Arrays.toString(strArray)); //Output 2.
return strArray;
}
我的问题是这样的:
- 第一个输出:
[-2,-8] [8,-4] [-3,2] [4,-1] - 第二个输出:
[[-2,-8] [8,-4] [-3,2] [4,-1]]。
现在我想要相同的输出(相同)。我该怎么做?谢谢!
【问题讨论】:
-
怎么了?你也可以添加 Soluzioni.txt 吗?
-
当然,Soluzioni.txt 是 [-2,-8] [8,-4] [-3,2] [4,-1]
-
[]由 Arrays.toString 添加。你的数组中没有它 -
@SnakeDoc 为什么?它是意大利语(或具有相同单词的其他语言)
-
好的,抱歉这个白痴问题。我太菜鸟了谢谢。