java获取传真文件的页数
时间:2010-03-02 来源:renmiaogen
public static int getTIFFPageNum(String srcPath) {
File srcFile = new File(srcPath); InputStream fis = null; try {
fis = new FileInputStream(srcFile); TIFFDecodeParam decodeParam = new TIFFDecodeParam();
ImageDecoder decoder = ImageCodec.createImageDecoder("TIFF", fis,
decodeParam);
return decoder.getNumPages();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != fis) {
fis.close();
}
} catch (Exception e) {
}
}
return 0;
}
File srcFile = new File(srcPath); InputStream fis = null; try {
fis = new FileInputStream(srcFile); TIFFDecodeParam decodeParam = new TIFFDecodeParam();
ImageDecoder decoder = ImageCodec.createImageDecoder("TIFF", fis,
decodeParam);
return decoder.getNumPages();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != fis) {
fis.close();
}
} catch (Exception e) {
}
}
return 0;
}
相关阅读 更多 +