这段代码为何会写入的是字符,而不是int;
package stream;
import java.io.IOException;
import java.io.FileWriter;
public class FileWriterTest {
public static void main(String[] args)
{
try
{
FileWriter fw = new FileWriter("D://demo/test.txt");
char c1 = 'a';
char c2 = '国';
char c3 = 'b';
fw.write((int)c1);
fw.write((int)c2);
fw.write((int)c3);
fw.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
fw.write((int)c1 + "");
fw.write((int)c2 + "");
fw.write((int)c3 + "");
fw.write(String.valueOf((int) c1));
fw.write(String.valueOf((int) c2));
fw.write(String.valueOf((int) c3));