:sad: Hi ,I have a text file and it contains a message ,I want to extract the last four characters in this file and then convert it to integer i did the following:
FileInputStream Received_Message=new FileInputStream ("MyFile.txt");
BufferedReader buff2=new BufferedReader(new InputStreamReader(Received_Message));
System.out.println("Your Received message is as following:");
while((recv_Message=buff2.readLine() )!=null){
System.out.println(recv_Message);
}
four_characters=recv_Message.substring(recv_Message.length() - 4);
Four_characters_Integers = Integer.parseInt(four_characters);
i sure have try and catch and defined all varibles above
but the problem it gives me this message when i use this statement:
four_characters=recv_Message.substring(recv_Message.length() - 4);
the Exception is as following:
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:373)
at java.lang.Integer.parseInt(Integer.java:454)
at final_append.CopyBytes.main(CopyBytes.java:101)
Exception in thread "main"
how can i solve this??plz any help in