I need to check every charackter in file and cast it on byte. But unfortunetely scanner not gives any possibilities to not spliting last charackter of line... I try to do something like this :
Scanner in = new Scanner(new File(path));
List<Byte> byteList = new ArrayList<>();
while (in.hasNextLine()) {
String a = in.nextLine();
if (in.hasNextLine()) {
a = a + (char) (13);
}
for (char c : a.toCharArray()) {
byteList.add((byte) c);
}
}
byte[] bytes = new byte[byteList.size()];
for (int i = 0; i < byteList.size(); i++) {
bytes[i] = byteList.get(i);
}
return bytes;
}
Have you maybe any idea for the solution on this problem ? I'll be grateful for your help.