1 23 24 29 package com.sun.enterprise.management.deploy; 30 31 import java.io.File ; 32 import java.io.FileOutputStream ; 33 import java.io.IOException ; 34 35 42 final class DownloadFileSource 43 { 44 private final String mModuleID; 45 private final String mFilename; 46 47 public 48 DownloadFileSource( 49 final String moduleID, 50 final String filename ) 51 throws IOException 52 { 53 mModuleID = moduleID; 54 mFilename = filename; 55 } 56 57 public File 58 getDownloadFile() 59 throws IOException 60 { 61 return( createDownloadFile( mModuleID, mFilename ) ); 62 } 63 64 public boolean 65 isTempFile() 66 { 67 return( true ); 68 } 69 70 74 private File 75 createDownloadFile( 76 final String moduleID, 77 final String filename) 78 throws IOException 79 { 80 final String name = "./" + moduleID + "_" + filename + System.currentTimeMillis(); 81 82 final File theFile = new File ( name ); 83 theFile.createNewFile(); 84 85 final FileOutputStream out = new FileOutputStream ( theFile ); 86 87 final byte[] temp = new byte[ 1024 * 1024 ]; 88 89 long remaining = temp.length * 10; 90 while ( remaining != 0 ) 91 { 92 out.write( temp ); 93 assert( remaining >= temp.length ); 94 remaining -= temp.length; 95 } 96 97 out.close(); 98 99 return( theFile ); 100 } 101 } 102 103 | Popular Tags |