Попробуйте этот пример кода,
FileInputStream in = null;
StringBuilder sb = new StringBuilder();
String tempString = null;
Reader initialReader;
try {
in = new FileInputStream(filename);
initialReader = new InputStreamReader(in);
char[] arr = new char[8 * 1024];
StringBuilder buffer = new StringBuilder();
int numCharsRead;
while ((numCharsRead = initialReader.read(arr, 0, arr.length)) != -1) {
buffer.append(arr, 0, numCharsRead);
}
String targetString = buffer.toString();
result = IOUtils.toByteArray(targetString);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}