File file = new File("path/to/file"); byte[] fileData = new byte[(int) file.length()]; try (FileInputStream fileInputStream = new FileInputStream(file)) { fileInputStream.read(fileData); } catch (IOException e) { e.printStackTrace(); } byte[] encodedFileData = Base64.getEncoder().encode(fileData); byte[] decodedFileData = Base64.getDecoder().decode(encodedFileData); try (FileOutputStream fileOutputStream = new FileOutputStream("path/to/outputfile")) { fileOutputStream.write(decodedFileData); } catch (IOException e) { e.printStackTrace(); }


上一篇:
下一篇:
切换中文