r15*_*abh 3 java try-catch program-flow jodconverter
我正在使用JODConverter将.xls和.ppt转换为.pdf格式.为此,我有类似的代码
try{
//do something
System.out.println("connecting to open office");
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
System.out.println("connection object created");
connection.connect();
System.out.println("connection to open office successful");
//do something
if(!successful)
throw new FileNotFoundException();
}catch(Exception e){
System.out.println("hello here");
System.out.println("Caught Exception while converting to PDF ");
LOGGER.error("Error in converting media" + e.getMessage());
throw new MediaConversionFailedException();
}finally{
decode_pdf.closePdfFile();
System.out.println("coming in finally");
//do something here
}
Run Code Online (Sandbox Code Playgroud)
我的输出:
connecting to open office
connection object created
coming in finally
Run Code Online (Sandbox Code Playgroud)
PS返回类型的方法是 void
这怎么可能 ?即使connection.connect()中存在一些问题,它也会进入catch块.困惑
| 归档时间: |
|
| 查看次数: |
534 次 |
| 最近记录: |