io
字符串转字节数组
string.getBytes()
string.getBytes(“utf-8”)
字节数组转字符串
new string(byte[])
new string(byte[],int offset,int len)
输出
void write(byte)
void write(bytes[])
输入
int read() 返回读取结果 结尾返回-1
int read(bytes[])
fileoutputstream 输出字符串到文件
fileoutputstream fos = new fileoutputstream(path);
fos.write("你好".getbytes("utf-8"));
fos.write()
fileinputstream 读取字符串到内存
fileintputstream fis = new fileinputstream(path);
int len = 0;
byte[] bytes = new byte[];
int offset = 0;
while((len = fis.read(bytes)) != -1)
{
sys(new string(bytes,0,len));
offset += len;
}