java IO复制文件 jpg txt mp3 等

 

 

File input = new File("D:/MJ.xml");

File output = new File("D:/wangzhi.xml");

byte[] bs = new byte[1024];

// if(!output.isFile()){

// output.createNewFile();

// }

InputStream inputStream = input.toURL().openStream();

OutputStream outputStream = new FileOutputStream(output);

while(true){

int readCount = inputStream.read(bs);

if(readCount == -1){

break;

}

outputStream.write(bs, 0, readCount);

}

inputStream.close();

outputStream.close();

你可能感兴趣的:(java,xml)