I have added comments to the main source file.
This commit is contained in:
20xd6 2021-08-04 11:01:25 -04:00
parent 06edfbd3b0
commit a855a5760a

View File

@ -34,6 +34,11 @@ import java.util.Base64;
public class File64 { public class File64 {
/*
This function transforms a binary file to byte[] array.
This allows it to be turned into a base64 encoded string suitable for use in
JSON.
*/
private static byte[] file_to_byte(File input_file) throws FileNotFoundException, IOException { private static byte[] file_to_byte(File input_file) throws FileNotFoundException, IOException {
byte[] file_bytes; byte[] file_bytes;
try (InputStream file_stream = new FileInputStream(input_file)) { try (InputStream file_stream = new FileInputStream(input_file)) {
@ -56,7 +61,7 @@ public class File64 {
} }
/** /**
* * The default interface. Files or strings are ingested and returned from here.
* @param to_encode * @param to_encode
* @param is_path * @param is_path
* @return * @return
@ -73,8 +78,6 @@ public class File64 {
} else if (!is_path) { } else if (!is_path) {
encoded_string = Base64.getEncoder().encodeToString(to_encode.getBytes()); encoded_string = Base64.getEncoder().encodeToString(to_encode.getBytes());
} }
// byte[] decoded_bytes = Base64.getDecoder().decode(encoded_string);
// String decoded_string = new String(decoded_bytes);
return encoded_string; return encoded_string;
} }
} }