我正在尝试访问 Java 中的文本文件,但是,我不知道该怎么做并将其应用于 2D 数组。我以前在猪拉丁编码分配 ex 中为 String 做过:
public static void piglatenizeFile(Scanner infile, String filename) throws IOException{
PrintWriter outFile = new PrintWriter(filename);
while(infile.hasNext()){
String s = infile.nextLine();
String p = pig(s);
outFile.println(p);
}
outFile.close();
}
然而,这是我必须做的:
/* creates scanner for filename
creates 2D array based on row/col
and characters in file
*/
public static char[][] read(String filename) throws FileNotFoundException{
}
它如何与二维数组一起工作?