为什么这里可以将char类型的写入输出流,我在查询到的方法只有
write(byte[] b),
write(byte[], int off, int len),
write(int b);
三种?是不是char类型的可以向上传递给int型?求各位高手赐教!import java.io.*;
public class FileIo
{
public static void main(String[] args)
{
char ch;
…………
try
{
…………
while((ch = (char)System.in.read()) != '#')
fout.write(ch); // MARK!!!
……………… }
catch (FileNotFoundException e)
{
System.err.println(e.getMessage());
}
catch (IOException e)
{
System.out.println(e.toString());
}
}
}
write(byte[] b),
write(byte[], int off, int len),
write(int b);
三种?是不是char类型的可以向上传递给int型?求各位高手赐教!import java.io.*;
public class FileIo
{
public static void main(String[] args)
{
char ch;
…………
try
{
…………
while((ch = (char)System.in.read()) != '#')
fout.write(ch); // MARK!!!
……………… }
catch (FileNotFoundException e)
{
System.err.println(e.getMessage());
}
catch (IOException e)
{
System.out.println(e.toString());
}
}
}
如果不换流,就可以
java.io.FileOutputStream out;
....
out.write((char+"").getBytes());