0
我已經在第一則兩個字符串全部三個0或1以下文本文件以逗號分隔:編輯文本文件中單個字符(JAVA)
0 , Bx , Cz
1 , By , Cx
0 , Bz , Cy
etc. , etc. , etc.
而且我有以下代碼:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Scanner;
public class Manager {
static Scanner scanner;
public Manager() {
}
public static void chooseFile(String thisFile) {
try {
scanner = new Scanner(new File(thisDeck));
scanner.useDelimiter(",");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
static String getB() {
String b = null;
if (scanner.hasNextLine()) {
String a = scanner.next();
do {
if (a.equals("1")) {
scanner.nextLine();
a = scanner.next();
}
if (a.equals("0")) {
b = scanner.next();
}
} while (scanner.hasNextLine() && a.equals("1"));
}
if (!scanner.hasNextLine()) {
b = 「Done.」;
}
return b;
}
static String getC() {
String c = null;
if (scanner.hasNextLine()) {
c = scanner.nextLine().substring(2);
} else {
c = 「Done.」;
}
return c;
}
static void changeA1() {
//Here I want to change a value in the first "column" A to 1
//The row/line to be changed is the one that the scanner just passed
}
static void changeA0() {
//Here I want to change a value in the first "column" A to 0
//The row/line to be changed is the one that the scanner just passed
}
}
我的問題是如何將值A更改爲0或1? GUI(調用該類)只允許用戶在調用getB()和getC()之後更改值A,因此掃描程序位於該行的末尾,用於更改a的值A的函數行將被調用。我可以使用第二臺掃描儀編輯數值-A還是有其他方法?
真的很難理解你的問題,也許是因爲缺少代碼,也許是因爲我無法理解你喜歡哪個輸出,試着編輯你的問題,我確信在線的人會給你一個答案 –
說明您想要實現的更改類型:將所有「a」更改爲零?將所有「a」改爲?將0更改爲1,反之亦然? –