日期:2014-05-20 浏览次数:20769 次
public class Stream { public static void main(String[] args) throws IOException { FileInputStream in = new FileInputStream(new File("F:\\a.exe")); FileOutputStream out = new FileOutputStream(new File("C:\\b.exe")); System.out.println(in.available()); byte buf[] = new byte[1024]; int size = -1; int sum = in.available(); while ((size=in.read(buf,0,buf.length)) != -1) { if(size < 1024){ // System.out.println("再写入-->"+size); out.write(size); }else{ // System.out.println("写入-->" + size); out.write(buf); } } out.flush(); out.close(); in.close(); } }
public class Stream { public static void main(String[] args) throws IOException { FileInputStream in = new FileInputStream(new File("F:\\a.exe")); FileOutputStream out = new FileOutputStream(new File("C:\\b.exe")); System.out.println(in.available()); byte buf[] = new byte[1024]; int size = -1; int sum = in.available(); while ((size=in.read(buf,0,buf.length)) != -1) { out.write(buf,0,size); } out.flush(); out.close(); in.close(); } }