Closed ghost closed 7 years ago
Can you post the code you were running when this exception was thrown?
import java.io.*;
public class VideoStream {
FileInputStream fis;
int frame_nb;
public VideoStream(String filename) throws Exception{
fis = new FileInputStream(filename);
frame_nb = 0;
}
public int getnextframe(byte[] frame) throws Exception
{
int length = 0;
String length_string;
byte[] frame_length = new byte[5];
fis.read(frame_length,0,5);
length_string = new String(frame_length);
length = Integer.parseInt(length_string); // here's give me NumberformatException
return(fis.read(frame,0,length));
}
}
The first 5 bytes in the video frame it is expecting an integer which tells it how much to read. Looks like the error was thrown when it can't parse the integer. Are you using a different video than the one provided in this project? If you do a printf on length_string
you could see what is the string that is causing the problem.
Closing this issue
Exception in thread "main" java.lang.NumberFormatException: For input string: " at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:569) at java.lang.Integer.parseInt(Integer.java:615) at VideoStream.getnextframe(VideoStream.java:35) at testing.main(testing.java:14)