Skip to content

Instantly share code, notes, and snippets.

@Tomut0
Created September 5, 2021 17:00
Show Gist options
  • Save Tomut0/67b116092e63b69b3fadea9d3d8a56c6 to your computer and use it in GitHub Desktop.
Save Tomut0/67b116092e63b69b3fadea9d3d8a56c6 to your computer and use it in GitHub Desktop.
public String encode(File file, String charset) throws IOException {
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
ByteArrayOutputStream buf = new ByteArrayOutputStream();
int result = bis.read();
while(result != -1) {
buf.write((byte) result);
result = bis.read();
}
return buf.toString(charset);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment