import java.io.*;
//号码薄示例
class IOUse
{
static FileOutputStream myFileOutputStream;
public static final int lineLength=81;

public static void main(String args[]) throws IOException
{
byte[] phone=new byte[lineLength];
byte[] name=new byte[lineLength];
//实例化FileOutputStream对象
myFileOutputStream=new FileOutputStream("e:\\aaa.txt");

while(true)
{
System.out.println("Please enter a name(enter 'done' to quit):");
//从终端读取数据后向FileOutputStream对象写入数据
readLine(name);
if("done".equalsIgnoreCase(new String(name,0,0,4)))
{
break;
}
System.out.println("Enter the phone number:");
readLine(phone);
for(int i=0;phone[i]!=0;i++)
{
myFileOutputStream.write(phone[i]);
}
myFileOutputStream.write(',');
for(int i=0;name[i]!=0;i++)
{
myFileOutputStream.write(name[i]);
}
myFileOutputStream.close();
}
}

private static void readLine(byte line[])throws IOException
{
int i=0,b=0;
while((i<(lineLength-1))&&((b=System.in.read())!='\n'))
{
line[i++]=(byte)b;
}
line[i]=(byte)0;
}
}
Please enter a name(enter 'done' to quit):
caofeng
Enter the phone number:
12345
Please enter a name(enter 'done' to quit):
done
在我的文件里面输出的是:caofeng ,12345  不知道为什么,我复制粘贴到这里面的时候,后面的黑色方块又没了,但在我文件里面canfeng和12345后面是分别有一个黑色的方块的,谁给我解释下,谢谢了~~~