public class FileCopy { public static void main(String[] args) { String path = "d:\\1.txt"; String newPath = "d:\\2.txt"; try { InputStream is = new FileInputStream(path); OutputStream os = new FileOutputStream(newPath); int len = 0; byte[] b = new byte[1024]; while((len = is.read(b)) != -1) os.write(b,0,len); os.close(); is.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
入出len byte while 关