Base64 encode data: Difference between revisions
Content added Content deleted
Line 1,192: | Line 1,192: | ||
</syntaxhighlight> |
</syntaxhighlight> |
||
<syntaxhighlight lang="java"> |
<syntaxhighlight lang="java"> |
||
byte[] encodeFile(String path) throws IOException { |
|||
try (FileInputStream stream = new FileInputStream(path)) { |
try (FileInputStream stream = new FileInputStream(path)) { |
||
byte[] bytes = stream.readAllBytes(); |
byte[] bytes = stream.readAllBytes(); |
||
return Base64.getEncoder(). |
return Base64.getEncoder().encode(bytes); |
||
} |
} |
||
} |
} |