rendered paste bodypackage SQL;import java.util.*;import java.io.*;/* * Fil ting: * java.io.inputstream */public class FileUpload { public final int MAX_CHUNK_TRANSFER_B = 65536; // 64 KB/s. public final int MAX_FILE_SIZE_B = 102400000; // 100 MB. private final String UPLOAD_TEMP_DIR = "./UPLOAD_TEMP"; private Hashtable<String, FileUploadObject> userObjectRelations = new Hashtable<String, FileUploadObject>(); public static void main(String[] args) { } /* * Initiate upload. */ public String initiateUpload() /* throws SystemException */ { // String sessionUserID = Kernel.getMySession().getUserId(); String sessionUserID = "thomas_1"; try { FileUploadObject FileUploadObject = new FileUploadObject(sessionUserID, UPLOAD_TEMP_DIR +"/"+ sessionUserID +".dat", 1024); userObjectRelations.put(sessionUserID, FileUploadObject); } catch (Exception e) { // throw new SystemException("Unable to create upload-session.", e); } return sessionUserID; } public FileUploadObject getUserObjectRelations(String sessionUserID) { FileUploadObject FileUploadObject = userObjectRelations.get(sessionUserID); return FileUploadObject; } /* private boolean freeUnusedIDHandle(String key) { boolean ret = false; return ret; } private int getNewIDHandle() { int ret = 0; int i = 0; boolean bool = true; while (bool == true) { if (userObjectRelations.containsKey("__KEY__")) { this.freeUnusedIDHandle("__KEY__"); ret = 0; //"__KEY__" bool = false; } } return ret; } */ class FileUploadObject { private Date packagaCreateDate, lastPackageDate = null; private long bytesResceived = 0; private long fileSize = 0; private String sessionUploadID = null; private FileOutputStream stream = null; public FileUploadObject(String uploadID, String path, long fileSize) throws IOException { this.sessionUploadID = uploadID; this.fileSize = fileSize; this.packagaCreateDate = new Date(); stream = new FileOutputStream(path); } public void packageResceived(byte[] dataPackage) throws IOException { this.lastPackageDate = new Date(); this.bytesResceived += dataPackage.length; stream.write(dataPackage); } public void test() { System.out.println("asdasd"); } public boolean completeUpload(String uploadID) { boolean ret = false; return ret; } public void closeSession() throws IOException { this.stream.close(); } public Date getCreateDate() { return this.packagaCreateDate; } public Date getLastPackageDate() { return this.lastPackageDate; } }}