package com.xqx;
import java.io.*;
/**
* createAuthor:xingquanxiang
* createTime:2019/8/20 14:34
* description:
* 文件复制,编码自动转换为utf-8
* 支持复制的文件编码:utf-8、Unicode、GBK、UTF-16BE
*/
public class CopyFile {
public static void main(String[] args) throws IOException {
//创建源文件对象
File srcFile = new File("E:\\DarkHorseLearn\\feiq\\Recv Files\\practice1.txt");
//获得源文件名称
String fileName = srcFile.getName();
//创建复制目的地文件父对象
File destFolder = new File("G:\\DarkHorseCode\\JavaSE_2\\problemSolving\\src");
//判断文件夹是否存在,不存在就创建
if (!destFolder.exists()) {
destFolder.mkdirs();
}
//创建字符输入流读取文件
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(srcFile),encoding(srcFile.getAbsolutePath())));
} catch (Exception e) {
文件复制,编码自动转换为utf-8,支持utf-8、Unicode、GBK、UTF-16BE
最新推荐文章于 2021-05-24 07:41:16 发布