import java.io.*; /** * 输入一行字符,存入到文件 line.txt中 */ 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); } } }