2019独角兽企业重金招聘Python工程师标准>>>
1.照片
2.代码
package cn.jointframe.com;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* 文件的拷贝
* 使用字节流 的输入流 和输出流 将文件 "杨钰莹 - 小情歌.mp3" 从磁盘E中复制到磁盘D:\text文件夹中
*/
public class Copy {
@SuppressWarnings("resource")
public static void main(String[] args) throws IOException {
//1.创建字节输入流 用于读取E盘下的源文件
InputStream in = new FileInputStream("E:/杨钰莹 - 小情歌.mp3");
//2.创建 字节输出流 用于将读到的数据写到目标位置 D:\text文件夹中
OutputStream out = new FileOutputStream("D:/text/杨钰莹 - 小情歌.mp3");
//3.定义一个变量用于接收每次读取的一个字节
int temp;
while((temp=in.read())!=-1){
out.write(temp);
}
//4.关流
out.close();
in.close();
}
}