文件字符串我有兩個文件:通過比較字符串
Grader.getFileInfo("data\\studentSubmissionA.txt");
Grader.teacherFiles("data\\TeacherListA.txt");
兩者都包含的數學問題的列表,但TeacherList是未解,以檢查StudentSubmission不是從原版本的。
studentSubmission發送到平地機類和方法目前看起來是這樣的:
public static void getFileInfo(String fileName)
throws FileNotFoundException {
Scanner in = new Scanner(new File(fileName))
while (in.hasNext()) {
String fileContent = in.nextLine();
}
和TeacherFiles方法看起來像
public static void teacherFiles(String teacherFiles)
throws FileNotFoundException{
Scanner in = new Scanner(new File(teacherFiles));
while (in.hasNext()){
String teacherContent = in.nextLine();
String line = teacherContent.substring(0, teacherContent.indexOf('='));
}
我不知道如何獲得這些方法另一種方法是爲了比較它們,因爲它們來自一個文件,我必須在方法簽名中加入一些東西來傳遞它們,但它不起作用。
我試圖把它們放在一個方法中,但是那也是一個半身像。
我不知道該從哪裏出發。我不能使用try/catch或數組。
是否可以通過方法發送.substring(0,.indexof('='))?
贊line = teacherFiles(teacherContent.substring(0 , .indexof('=')));
可以做到這一點嗎?
這是實驗工作,我不能使用數組。如果可以的話,這將是一百萬倍更簡單,我不會問。 – CherryBomb95
我該怎麼做呢? – CherryBomb95
好的,謝謝。 – CherryBomb95