数组的动态性不好。建议先用List<String[]>,若需要,再转化为二维数组
public class $ {
public static void main(String[] args) {
List<String[]> data = new ArrayList<>();
try {
Scanner in = new Scanner(new File("D:/a.txt"));
while (in.hasNextLine()) {
String str = in.nextLine();
data.add(str.split(" ,|"));
}
} catch (Exception e) {
e.printStackTrace();
}
// list转化为数组
String[][] result = data.toArray(new String[][] {});
for (String[] strings : result) {
for (String string : strings) {
System.out.print(string + " ");
}
System.out.println();
}
}
}
追问有企鹅么 ?希望能够 得到 帮助
追答1 2 1 6 6 5 6 8 9
本回答被提问者和网友采纳