Created
September 14, 2022 04:09
-
-
Save OmkarKirpan/af066cbd01ca72ad3be6074a06b62dc0 to your computer and use it in GitHub Desktop.
Revisions
-
OmkarKirpan created this gist
Sep 14, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ 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<String> 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(); } } }