直接上代码:
import java.io.*; class Test{ public static void main(String[] args){ FileInputStream inputfile = null; FileOutputStream outputfile = null; try{ inputfile = new FileInputStream("./input.txt"); outputfile = new FileOutputStream("./output.txt"); byte[] buffer = new byte[100]; int temp = inputfile.read(buffer,0,buffer.length); String s = new String(buffer); s = s.trim(); System.out.println(s); outputfile.write(buffer,0,temp); } catch(Exception e){ System.out.println(e); } } }