out.flush();
out.close();
}
catch ( FileNotFoundException e )
{
new ExceptionHandler().handleException( new Status( IStatus.ERROR, BrowserUIPlugin.PLUGIN_ID,
IStatus.ERROR, "Can't write to file", e ) );
}
catch ( IOException e )
{
new ExceptionHandler().handleException( new Status( IStatus.ERROR, BrowserUIPlugin.PLUGIN_ID,
IStatus.ERROR, "Can't write to file", e ) );
}
}
}
else if ( buttonId == LOAD_BUTTON_ID )
{
FileDialog fileDialog = new FileDialog( getShell(), SWT.OPEN );
fileDialog.setText( "Load Data" );
String returnedFileName = fileDialog.open();
if ( returnedFileName != null )
{
try
{
File file = new File( returnedFileName );
FileInputStream in = new FileInputStream( file );
ByteArrayOutputStream out = new ByteArrayOutputStream( ( int ) file.length() );
byte[] buf = new byte[4096];
int len;
while ( ( len = in.read( buf ) ) > 0 )
{
out.write( buf, 0, len );
}
this.currentData = out.toByteArray();
hexText.setText( toFormattedHex( this.currentData ) );
out.close();
in.close();
}
catch ( FileNotFoundException e )
{
new ExceptionHandler().handleException( new Status( IStatus.ERROR, BrowserUIPlugin.PLUGIN_ID,
IStatus.ERROR, "Can't read file", e ) );
}
catch ( IOException e )
{
new ExceptionHandler().handleException( new Status( IStatus.ERROR, BrowserUIPlugin.PLUGIN_ID,
IStatus.ERROR, "Can't read file", e ) );
}
}
}
else