【发布时间】:2018-03-11 15:13:17
【问题描述】:
package file;
import java.io.*;
public class x {
public static void main(String[] args) {
try {
FileWriter fs = new FileWriter("ahmed.txt");
fs.write("21");
fs.close();
FileReader fr = new FileReader("ahmed.txt");
//String x = Integer.toString(fr.read());
int x = fr.read();
System.out.println(x);
fr.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
当输入为 20 和 21 时 x 的输出值为 50 我该怎么办 把输入变成输出
【问题讨论】:
-
听起来像是在读取字节,因为 2 的 ASCII 值是
50。 -
嗯,它正在读取单个字符。这可能包含多个字节。但它肯定不会读取多个字符。
标签: java