总结:
没体会到
package com.a.b; import java.io.*; public class tsetOut { public static void main(String[] args) throws IOException { char ch; int i; File newDir=new File("C:\JavaTest2"); if(!newDir.exists()){ newDir.mkdir(); File newFile=new File(newDir,"newTest.txt"); FileOutputStream outS=new FileOutputStream(newFile); System.err.println("input characters for file ende#:"); while((ch=(char)System.in.read())!='#'){//这里注意转化,int---->char大字节到小字节强制转换 outS.write(ch); outS.close(); System.out.println("input finished"); System.out.println(""); System.out.println("now read file and output:"); FileInputStream fis=new FileInputStream(newFile); while((i=fis.read())!=-1){ System.out.println((char)i); fis.close(); } } } } }