import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Base64; import java.util.List; public class FilesReadFileExample { public static void main(String[] args) { Path path = Paths.get("infile.jks"); Path outpath = Paths.get("outfile.jks"); try { byte[] bs = Files.readAllBytes(path); // List strings = Files.readAllLines(path, StandardCharsets.UTF_8); String plaintxt = new String(bs); System.out.println("Read bytes: \n"+new String(bs)); System.out.println("Read lines: \n"+plaintxt); byte[] asBytes = Base64.getDecoder().decode(bs); // String base64Decoded = new String(asBytes, StandardCharsets.UTF_8); // System.out.println("Base64 decoded text: " + base64Decoded); Path writtenFilePath = Files.write(outpath, asBytes); System.out.println("writtenFilePath: \n"+writtenFilePath.toAbsolutePath()); } catch (Exception e) { e.printStackTrace(); } } }