我需要能够操纵字符串中的每个字符。有人能告诉我我在这里做错了什么吗?Java 7问题逐字符读取
import java.io.*;
public class encryptedWrite {
public static void main(String[] args) {
try {
File file = new File("code.txt");
// if file doesnt exists, then create it
if (!file.exists()) {
file.createNewFile();
}
BufferedReader read
= new BufferedReader(new InputStreamReader(System.in));
int charNumber = 0;
String content = read.readLine();
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
String numberString = charNumber + "";
String modCont = content.charAt(numberString);
while (!(modCont.equals("#"))) {
bw.write(modCont);
charNumber++;
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
我需要能够输出每个字符的内容code.txt。
,你得到什么输出,并且为什么错了?我们无法读懂你的想法。 – awksp