62,614
社区成员
发帖
与我相关
我的任务
分享
import java.util.*;
import java.io.*;
public class a5 {
public static void main(String[] args) {
int Number[ ] = new int [100];
file("D:\\a.txt");
}
public void file(String file) {
List<String[]> data = new ArrayList<>();
try {
Scanner in = new Scanner(new File(file));
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();
}
}
}
import java.util.*;
import java.io.*;
public class test {
static List<String> list= new ArrayList<String>();
public static void main(String[] args) {
int Number[] = new int[100];
file("D:\\a.txt");
for(int i=0;i<list.size();i++) {
Number[i]=Integer.parseInt(list.get(i));
}
}
public static void file(String file) {
List<String[]> data = new ArrayList<>();
try {
Scanner in = new Scanner(new File(file));
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) {
list.add(string);
}
}
}
}