http://pzh17rfak.bkt.clouddn.com/AmaterasUML.zip
    http://pzh17rfak.bkt.clouddn.com/AmaterasUML.txt

    public static void main(String[] args) {
    // String srcpath = “C:\Users\os-lusd\Desktop\zip\node-v10.4.0-x64.zip”;
    // String mergepath = “C:\Users\os-lusd\Desktop\zip\node-v10.4.0-x64.txt”;
    // // 将源文件 读取 加密 写入到txt
    // Base64Tracsfer.srcFileEncoderTxt(srcpath, mergepath);
    // // 查分大小
    // Base64Tracsfer.splitFile(mergepath, Constant.FILE_DEFULT_SIZE);
    String splitpath = “C:\Users\os-lusd\Desktop\zip\node-v10.4.0-x641.txt”;
    String mergepath = “C:\Users\os-lusd\Desktop\zip\copynode-v10.4.0-x64.txt”;
    String tagpath = “C:\Users\os-lusd\Desktop\zip\copynode-v10.4.0-x64.zip”;
    int mergeFileNum = 21;
    // 合并
    Base64Tracsfer.MergeFile(splitpath, mergeFileNum, mergepath);
    // 将文本文件 读取 解密 写回原来文件
    Base64Tracsfer.txtdecoderSrcFile(mergepath, tagpath);
    System.out.println(“执行完成”);
    }

    /
    将源文件 读取 加密 写入到txt
    @param srcpath 源文件 路径
    @param txtpath 目标文件 路径
    /
    public static void srcFileEncoderTxt(String srcpath, String txtpath) {
    final Base64.Encoder encoder = Base64.getEncoder(); // 加密
    DataInputStream dis = null;
    DataOutputStream dos = null;
    try {
    dis = new DataInputStream(new FileInputStream(srcpath));
    dos = new DataOutputStream(new FileOutputStream(txtpath));
    int available = dis.available();
    byte[] b = null;
    int curr = 0;
    while (curr < available) {
    int start = curr;
    int len = Constant.INPUT_BUFFER_DEFULT_SIZE;
    if (start + len > available) {
    len = available - start;
    }
    curr = start + len;
    b = new byte[len];
    dis.read(b, 0, len);
    String encodedText = encoder.encodeToString(b) + “\n”;
    dos.write(encodedText.getBytes());
    }
    System.out.println(“加密前文件总大小:” + available);
    System.out.println(“加密后文件总大小:” + dos.size());
    System.out.println(“加密转化率:” + dos.size() * 100 / available + “%”);
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    } finally {
    if (dis != null) {
    try {
    dis.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    if (dos != null) {
    try {
    dos.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }
    }
    /

    将文件 读取 解密 写回原来文件

    @param txtpath 加密后的文件路径
    @param tagpath 解密后的文件路径
    /
    public static void txtdecoderSrcFile(String txtpath, String tagpath) {
    final Base64.Decoder decoder = Base64.getDecoder();
    BufferedReader dis = null;
    DataOutputStream dos = null;
    try {
    dis = new BufferedReader(new FileReader(txtpath));
    dos = new DataOutputStream(new FileOutputStream(new File(tagpath)));
    String str = null;
    int line = 0;
    while (true) {
    str = dis.readLine();
    if (str == null) {
    break;
    }
    ++line;
    System.out.println(“读取文件行数:” + line + “ 读取字符长度:” + str.length());
    byte[] decode = decoder.decode(str);
    dos.write(decode);
    }
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    if (dis != null) {
    try {
    dis.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    if (dos != null) {
    try {
    dos.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }
    }
    /**
    分割文件
    @param srcFile 源文件路径
    @param fileSize 每个文件大小
    /
    public static void splitFile(String srcpath, int fileSize) {
    DataInputStream dis = null;
    DataOutputStream dos = null;
    try {
    dis = new DataInputStream(new FileInputStream(srcpath));
    int available = dis.available();
    if (available > fileSize) {
    // 需要分割
    String name = srcpath.substring(0, srcpath.lastIndexOf(“.”));
    String suffix = srcpath.substring(srcpath.lastIndexOf(“.”));
    int filePart = 1;
    byte[] buffer = null;
    int curr = 0;
    while (curr < available) {
    int start = curr;
    int len = fileSize;
    if (start + len > available) {
    len = available - start;
    }
    curr = start + len;
    buffer = new byte[len];
    dis.read(buffer, 0, len);
    dos = new DataOutputStream(new FileOutputStream(name + (filePart++) + suffix));
    dos.write(buffer);
    }
    } else {
    System.out.println();
    }
    } catch (Exception e) {
    // TODO: handle exception
    } finally {
    if (dis != null) {
    try {
    dis.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    if (dos != null) {
    try {
    dos.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }
    }

    /**
    合并文件
    @param txtpath 合并的第一个文件
    @param fileNum 需要合并 文件个数
    @param srcPath 合并后的文件名称
    /
    public static void MergeFile(String txtpath, int fileNum, String srcPath) {
    DataInputStream dis = null;
    DataOutputStream dos = null;
    try {
    String name = txtpath.substring(0, txtpath.lastIndexOf(“.”)-1);
    String suffix = txtpath.substring(txtpath.lastIndexOf(“.”));
    dos = new DataOutputStream(new FileOutputStream(srcPath));
    for (int filePart = 1; filePart <= fileNum; filePart++) {
    dis = new DataInputStream(new FileInputStream(name + filePart + suffix));
    int available = dis.available();
    byte[] b = null;
    int curr = 0;
    while (curr < available) {
    int start = curr;
    int len = Constant.INPUT_BUFFER_DEFULT_SIZE;
    if (start + len > available) {
    len = available - start;
    }
    curr = start + len;
    b = new byte[len];
    dis.read(b, 0, len);
    dos.write(b);
    }
    }

    } catch (Exception e) {
    // TODO: handle exception
    } finally {
    if (dis != null) {
    try {
    dis.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    if (dos != null) {
    try {
    dos.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }

    }

    // public static final int
    public static final String FILE_SUFFIX_TXT = “.txt”;
    public static final int INPUT_BUFFER_DEFULT_SIZE = 110241000;
    public static final int FILE_DEFULT_SIZE = 1024*1000;