private void print( String text ) { if ( pw == null ){ buffer.append( text ); if ( buffer.length() > 8*1024 ){ if ( poop_file == null ){ try{ poop_file = AETemporaryFileHandler.createTempFile(); }catch( Throwable e ){ } } if ( poop_file != null ){ try{ pw = new PrintWriter( new OutputStreamWriter( new FileOutputStream( poop_file ), "UTF-8" )); pw.print( buffer.toString()); }catch( Throwable e ){ } } buffer.setLength( 0 ); } }else{ pw.print( text ); } }
File result = createSemiTempFile();
public static boolean canWriteToDirectory( File dir ) { // (dir).canWrite() seems to return true for local file systems at least on windows regardless // of effective permissions :( if ( !dir.isDirectory()){ return( false ); } try{ File temp = AETemporaryFileHandler.createTempFileInDir( dir ); if ( !temp.delete()){ temp.deleteOnExit(); } return( true ); }catch( Throwable e ){ return( false ); } } /**
torrent_file = new File( AETemporaryFileHandler.getTempDirectory(), torrent_name ); torrent_file = AETemporaryFileHandler.createTempFile();
file = new File( AETemporaryFileHandler.createTempDir(), file_name ); file = new File( AETemporaryFileHandler.getTempDirectory(), file_name );
private File extractFromVuzeFile( File file ) throws PluginException { VuzeFile vf = VuzeFileHandler.getSingleton().loadVuzeFile(file); VuzeFileComponent[] comps = vf.getComponents(); for (int j=0;j<comps.length;j++){ VuzeFileComponent comp = comps[j]; if ( comp.getType() == VuzeFileComponent.COMP_TYPE_PLUGIN ){ try{ Map content = comp.getContent(); String id = new String((byte[])content.get( "id" ), "UTF-8" ); String version = new String((byte[])content.get( "version" ), "UTF-8" ); String suffix = ((Long)content.get( "is_jar" )).longValue()==1?"jar":"zip"; byte[] plugin_file = (byte[])content.get( "file" ); File temp_dir = AETemporaryFileHandler.createTempDir(); File temp_file = new File( temp_dir, id + "_" + version + "." + suffix ); FileUtil.copyFile( new ByteArrayInputStream( plugin_file ), temp_file ); return( temp_file ); }catch( Throwable e ){ throw( new PluginException( "Not a valid Vuze file", e )); } } } return( file ); }
public static File getTempDirectory() { startup(); return( tmp_dir ); }
if ( !f.equals(AETemporaryFileHandler.getTempDirectory())){
descriptor_dir = AETemporaryFileHandler.createTempDir();
public static File createTempFileInDir( File parent_dir ) throws IOException { startup(); return( File.createTempFile( PREFIX, SUFFIX, parent_dir )); }
temp_file = AETemporaryFileHandler.createTempFile();
File temp_dir = AETemporaryFileHandler.createTempDir();
public static File createTempFile() throws IOException { startup(); return( File.createTempFile( PREFIX, SUFFIX, tmp_dir )); }
final File torrent_file = AETemporaryFileHandler.createSemiTempFile( name + ".torrent" );
File temp_file = AETemporaryFileHandler.createTempFile();
File temp_dir = AETemporaryFileHandler.createTempDir();
public static File createTempDir() throws IOException { startup(); for (int i=0;i<16;i++){ File f = File.createTempFile( PREFIX, SUFFIX, tmp_dir ); f.delete(); if ( f.mkdirs()){ return( f ); } } throw( new IOException( "Failed to create temporary directory in " + tmp_dir )); } }
File tmp = AETemporaryFileHandler.createTempFile();
File temp_dir = AETemporaryFileHandler.createTempDir();
AETemporaryFileHandler.startup();