Examples of TempFile


Examples of kr.or.ioi2002.RMIServer.TempFile

            String language, String sourceFileName, byte[] sourceFileData) {
        User user = getUser(contest, userId);
        if (user == null)
            return false;

        TempFile tmp = null;
        try {
            tmp = TempFile.createFromByteArray(sourceFileData);
        } catch (java.io.IOException e) {
            Syslog.log("ContestManager: submit: " + e.toString());
            return false;
View Full Code Here

Examples of kr.or.ioi2002.RMIServer.TempFile

            throw new AgentException(
                    "!currentJob.userid == null || currentJob.task == null: doGrade");

        // store grader-generated files to the server
        // save csv and log as file
        TempFile tmpfilelog = TempFile.createFromByteArray(currentJob.log);
        saveGradeResultFile(currentJob.getContestId(),
                currentJob.getUserid(),
                currentJob.getTask(),
                tmpfilelog,
                currentJob.getTask() + "." + currentJob.getType() + ".grader.log");
        TempFile tmpfilecsv = TempFile.createFromByteArray(currentJob.getGradeResult().toString()
                .getBytes("UTF-8"));
        saveGradeResultFile(currentJob.getContestId(),
                currentJob.getUserid(),
                currentJob.getTask(),
                tmpfilecsv,
                currentJob.getTask() + "." + currentJob.getType() + ".grader.csv");

        // retreive filelist and recv files
        byte[] abyFilelist = recvBytes();
        String strFilelist = new String(abyFilelist);
        StringTokenizer tFile = new StringTokenizer(strFilelist, "\n");
        try {
            String strFilename = null;
            while (tFile.hasMoreTokens() && !(strFilename = tFile.nextToken().trim()).equals("")) {
                TempFile tmpFile = recvFile();
                saveGradeResultFile(currentJob.getContestId(), currentJob.getUserid(), currentJob
                        .getTask(), tmpFile, strFilename);
            }
        } catch (NoSuchElementException e) {
            throw new AgentException("!NoSuchElementException: doGrade");
View Full Code Here

Examples of org.apache.james.mime4j.message.storage.TempFile

    }

    public void testCreateTempFile() throws IOException {
        SimpleTempStorage man = new SimpleTempStorage();
        TempPath path = man.getRootTempPath().createTempPath();
        TempFile file = path.createTempFile();
        assertTrue(file.getAbsolutePath().startsWith(path.getAbsolutePath()));
       
        String fileName = file.getAbsolutePath().substring(
                file.getAbsolutePath().lastIndexOf(File.separatorChar) + 1);
        assertTrue("Unexpected chars in file name " + fileName,
                    fileName.matches("^[0-9]+\\.tmp$"));
        assertTrue("Temp file doesn't exist",
                   new File(file.getAbsolutePath()).exists());
       
        String s = "A short string";
        OutputStream out = file.getOutputStream();
        out.write(s.getBytes());
        out.close();

        byte[] buffer = new byte[s.length() * 2];
        InputStream in = file.getInputStream();
        int i = 0;
        for (int data; (data = in.read()) != -1; i++) {
            buffer[i] = (byte) data;
        }
        in.close();
View Full Code Here

Examples of org.apache.james.mime4j.message.storage.TempFile

    }
   
    public void testCreateTempFileStringString() throws IOException {
        SimpleTempStorage man = new SimpleTempStorage();
        TempPath path = man.getRootTempPath().createTempPath();
        TempFile file = path.createTempFile("test_prefix", ".suffix");
        assertTrue(file.getAbsolutePath().startsWith(path.getAbsolutePath()));
       
        String fileName = file.getAbsolutePath().substring(
                file.getAbsolutePath().lastIndexOf(File.separatorChar) + 1);
        assertTrue("Unexpected chars in file name " + fileName,
                    fileName.matches("^test_prefix[0-9]+\\.suffix$"));
        assertTrue("Temp file doesn't exist",
                   new File(file.getAbsolutePath()).exists());
    }
View Full Code Here

Examples of org.apache.james.mime4j.message.storage.TempFile

    }
   
    public void testDeleteTempFile() throws IOException {
        SimpleTempStorage man = new SimpleTempStorage();
        TempPath path = man.getRootTempPath().createTempPath();
        TempFile tempFile = path.createTempFile("test_prefix", ".suffix");

        File backingFile = new File(tempFile.getAbsolutePath());
        assertTrue(backingFile.exists());

        tempFile.delete();
        assertFalse(backingFile.exists());
    }
View Full Code Here

Examples of org.apache.james.mime4j.message.storage.TempFile

    }

    public void testCreateTempFile() throws IOException {
        SimpleTempStorage man = new SimpleTempStorage();
        TempPath path = man.getRootTempPath().createTempPath();
        TempFile file = path.createTempFile();
        assertTrue(file.getAbsolutePath().startsWith(path.getAbsolutePath()));
       
        String fileName = file.getAbsolutePath().substring(
                file.getAbsolutePath().lastIndexOf(File.separatorChar) + 1);
        assertTrue("Unexpected chars in file name " + fileName,
                    fileName.matches("^[0-9]+\\.tmp$"));
        assertTrue("Temp file doesn't exist",
                   new File(file.getAbsolutePath()).exists());
       
        String s = "A short string";
        OutputStream out = file.getOutputStream();
        out.write(s.getBytes());
        out.close();

        byte[] buffer = new byte[s.length() * 2];
        InputStream in = file.getInputStream();
        int i = 0;
        for (int data; (data = in.read()) != -1; i++) {
            buffer[i] = (byte) data;
        }
        in.close();
View Full Code Here

Examples of org.apache.james.mime4j.message.storage.TempFile

    }
   
    public void testCreateTempFileStringString() throws IOException {
        SimpleTempStorage man = new SimpleTempStorage();
        TempPath path = man.getRootTempPath().createTempPath();
        TempFile file = path.createTempFile("test_prefix", ".suffix");
        assertTrue(file.getAbsolutePath().startsWith(path.getAbsolutePath()));
       
        String fileName = file.getAbsolutePath().substring(
                file.getAbsolutePath().lastIndexOf(File.separatorChar) + 1);
        assertTrue("Unexpected chars in file name " + fileName,
                    fileName.matches("^test_prefix[0-9]+\\.suffix$"));
        assertTrue("Temp file doesn't exist",
                   new File(file.getAbsolutePath()).exists());
    }   
View Full Code Here

Examples of org.apache.james.mime4j.util.TempFile

    }

    public void testCreateTempFile() throws IOException {
        SimpleTempStorage man = new SimpleTempStorage();
        TempPath path = man.getRootTempPath().createTempPath();
        TempFile file = path.createTempFile();
        assertTrue(file.getAbsolutePath().startsWith(path.getAbsolutePath()));
       
        String fileName = file.getAbsolutePath().substring(
                file.getAbsolutePath().lastIndexOf(File.separatorChar) + 1);
        assertTrue("Unexpected chars in file name " + fileName,
                    fileName.matches("^[0-9]+\\.tmp$"));
        assertTrue("Temp file doesn't exist",
                   new File(file.getAbsolutePath()).exists());
       
        String s = "A short string";
        OutputStream out = file.getOutputStream();
        out.write(s.getBytes());
        out.close();

        byte[] buffer = new byte[s.length() * 2];
        InputStream in = file.getInputStream();
        int i = 0;
        for (int data; (data = in.read()) != -1; i++) {
            buffer[i] = (byte) data;
        }
        in.close();
View Full Code Here

Examples of org.apache.james.mime4j.util.TempFile

    }
   
    public void testCreateTempFileStringString() throws IOException {
        SimpleTempStorage man = new SimpleTempStorage();
        TempPath path = man.getRootTempPath().createTempPath();
        TempFile file = path.createTempFile("test_prefix", ".suffix");
        assertTrue(file.getAbsolutePath().startsWith(path.getAbsolutePath()));
       
        String fileName = file.getAbsolutePath().substring(
                file.getAbsolutePath().lastIndexOf(File.separatorChar) + 1);
        assertTrue("Unexpected chars in file name " + fileName,
                    fileName.matches("^test_prefix[0-9]+\\.suffix$"));
        assertTrue("Temp file doesn't exist",
                   new File(file.getAbsolutePath()).exists());
    }   
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.TempFile

     */
    public void transform() throws BuildException {
        checkOptions();
        Project project = task.getProject();

        TempFile tempFileTask = new TempFile();
        tempFileTask.bindToOwner(task);

        XSLTProcess xsltTask = new XSLTProcess();
        xsltTask.bindToOwner(task);

        xsltTask.setXslResource(getStylesheet());

        // acrobatic cast.
        xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile());
        File outputFile = null;
        if (format.equals(FRAMES)) {
            String tempFileProperty = getClass().getName() + String.valueOf(counter++);
            File tmp = FILE_UTILS.resolveFile(project.getBaseDir(),
                    project.getProperty("java.io.tmpdir"));
            tempFileTask.setDestDir(tmp);
            tempFileTask.setProperty(tempFileProperty);
            tempFileTask.execute();
            outputFile = new File(project.getProperty(tempFileProperty));
        } else {
            outputFile = new File(toDir, "junit-noframes.html");
        }
        xsltTask.setOut(outputFile);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.