import java.io.*; //把用户输入字符存入到文件中 public class Example10_5 { public static void main(String args[]) { int b; byte buffer[] = new byte[100]; try { System.out.println("输入一行文本,并存入磁盘:"); b = System.in.read(buffer); FileOutputStream writefile = new FileOutputStream("line.txt"); writefile.write(buffer, 0, b); } catch (IOException e) { System.out.println("Error" + e); } } }