private Object loadJNLP() throws UnavailableServiceException, IOException {
Window frame = getFrame();
// Get the JNLP service for opening files.
FileOpenService fos = (FileOpenService)ServiceManager.lookup( "javax.jnlp.FileOpenService" );
if( fos == null ) {
throw new UnavailableServiceException( "JNLP FileOpenService is unavailable" );
}
// Read the configuration from a file.
FileContents fc = fos.openFileDialog( _directoryName, null );
if( fc == null ) {
return null;
}
_directoryName = getDirectoryName( fc.getName() );
// Convert the FileContents to an input stream.
InputStream inputStream = fc.getInputStream();
// XML-decode the input stream.
Object object = null;
XMLDecoder decoder = new XMLDecoder( inputStream );
decoder.setExceptionListener( new ExceptionListener() {
private int errors = 0;
// Report the first recoverable exception.
public void exceptionThrown( Exception e ) {
if( errors == 0 ) {
showError( QWIResources.getString( "Load.error.decode" ), e );
errors++;
}
}
} );
object = decoder.readObject();
decoder.close();
return object;
}
PersistenceManager.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:PhET
作者:
评论列表
文章目录