//写入数据 File file=new File("d:"+File.separator+"demo.txt"); OutputStream out=new FileOutputStream(file,true);//在文件后追加 String str="hello world"; byte b[]=str.getBytes(); out.write(b); out.close(); //读取数据 File file1=new File("d:"+File.separator+"demo.txt"); InputStream in=new FileInputStream(file1); byte[] by=new byte[(int)file.length()];//根据文件大小开辟字节空间 in.read(by); System.out.println(by.toString());
现问:1 输入流 输出流是怎么命名的呀,写入数据为什么是用输出流呢,应该是用入流呀,thanks