我正面临一个问题,我有一个空指针异常,我正在尝试处理一个视频压缩程序,这是出现异常的部分:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FileInputStream fis=null;
File file=null;
try
{
URL uri=CompressionTest.class.getResource("/Files/Video.mp4");
file=new File(uri.getPath());
fis = new FileInputStream(file);
} 发布于 2015-03-25 23:10:29
使用前请检查uri是否为空:
if (uri===null) {
//Handle the situation, propably throw other exception
}
//rest of the code如果资源不可用,Class.getResource可能会返回null (如其documentation中所述)
https://stackoverflow.com/questions/29259333
复制相似问题