public static void writeBytesAsFile( String filename, byte[] file_data ) { // pftt, this is used by emp so can't fix signature to make more useful writeBytesAsFile2( filename, file_data ); }
public static boolean writeStringAsFile( File file, String text, String charset ) { try{ return( writeBytesAsFile2( file.getAbsolutePath(), text.getBytes( charset ))); }catch( Throwable e ){ Debug.out( e ); return( false ); } }
private File receiveQR( String ac, Map<String,Object> response ) { try{ byte[] bytes = (byte[])response.get( "qr_b" ); if ( bytes == null ){ return( null ); } long ver = (Long)response.get( "qr_v" ); File cache_dir = new File( SystemProperties.getUserPath(), "cache" ); File qr_file = new File( cache_dir, "qr_" + ac + "_" + ver + ".png" ); if ( FileUtil.writeBytesAsFile2( qr_file.getAbsolutePath(), bytes )){ return( qr_file ); } return( null ); }catch( Throwable e ){ Debug.out( e ); return( null ); } }
protected void importCustomization( Map map ) throws CustomizationException { try{ String name = new String((byte[])map.get( "name" ), "UTF-8" ); String version = new String((byte[])map.get( "version" ), "UTF-8" ); if ( !Constants.isValidVersionFormat( version )){ throw( new CustomizationException( "Invalid version specification: " + version )); } byte[] data = (byte[])map.get( "data" ); File user_dir = FileUtil.getUserFile("custom"); if ( !user_dir.exists()){ user_dir.mkdirs(); } File target = new File( user_dir, name + "_" + version + ".zip" ); if ( !target.exists()){ if ( !FileUtil.writeBytesAsFile2( target.getAbsolutePath(), data )){ throw( new CustomizationException( "Failed to save customization to " + target )); } } }catch( CustomizationException e ){ throw( e ); }catch( Throwable e ){ throw( new CustomizationException( "Failed to import customization", e )); } }
patched = FileUtil.writeBytesAsFile2( source.getAbsolutePath(), BEncoder.encode( m ));