/**
* 上传文件
* @param file
* @param path
* @param fileName
* @throws IOException
*/
public void fileLoad(File file, String path, String fileName)
throws IOException {
//上传文件路径+文件名
File target = new File(path+fileName);
//读取上传的文件
BufferedReader br = new BufferedReader(new FileReader(file));
//输出上传的文件
BufferedWriter bw = new BufferedWriter(new FileWriter(target));
//设置流量
char[] buf = new char[1024];
//开始上传
while(br.read(buf) != -1){
bw.write(buf);
}
bw.close();
br.close();
}
BufferedWriter和BufferedReader使用方法
时间: 2024-11-10 15:17:52