List of usage examples for org.apache.commons.lang SystemUtils JAVA_IO_TMPDIR
String JAVA_IO_TMPDIR
To view the source code for org.apache.commons.lang SystemUtils JAVA_IO_TMPDIR.
Click Source Link
The java.io.tmpdir
System Property.
From source file:edu.duke.cabig.c3pr.webservice.integration.C3PREmbeddedTomcatTestBase.java
private boolean isCatalinaHomeSafe() { if (catalinaHome.getParentFile() != null && (catalinaHome.getParentFile().equals(new File(SystemUtils.JAVA_IO_TMPDIR)) || catalinaHome.getParentFile().equals(new File("c:/temp")))) { return true; }// w ww. j av a2 s . c o m return false; }
From source file:jp.eflow.hisano.dalvikvm.VirtualMachineTest.java
private byte[] compile(File classesDirectory, String[] files) { String[] cmdarray = new String[files.length + 5]; cmdarray[0] = "javaw"; cmdarray[1] = "-jar"; cmdarray[2] = DX_JAR_FILE_PATH;// w w w. j av a 2 s . c o m cmdarray[3] = "--dex"; String dexFilePath = new File(SystemUtils.JAVA_IO_TMPDIR, FilenameUtils.getBaseName(files[0]) + ".dex") .getAbsolutePath(); cmdarray[4] = "--output=" + dexFilePath; System.arraycopy(files, 0, cmdarray, 5, files.length); try { Process process = Runtime.getRuntime().exec(cmdarray, null, classesDirectory); process.waitFor(); } catch (Exception e) { throw new IllegalStateException("Compiling failed.", e); } FileInputStream in = null; try { in = new FileInputStream(dexFilePath); return IOUtils.toByteArray(in); } catch (IOException e) { throw new IllegalStateException("Loading " + dexFilePath + " failed.", e); } finally { IOUtils.closeQuietly(in); } }
From source file:com.github.trugath.jdalvikvm.VirtualMachineTest.java
private byte[] compile(File classesDirectory, String[] files) { String[] cmdarray = new String[files.length + 5]; cmdarray[0] = "java"; cmdarray[1] = "-jar"; cmdarray[2] = new File(DX_JAR_FILE_PATH).getAbsolutePath(); cmdarray[3] = "--dex"; String dexFilePath = new File(SystemUtils.JAVA_IO_TMPDIR, FilenameUtils.getBaseName(files[0]) + ".dex") .getAbsolutePath();/*from ww w. j av a 2 s.co m*/ cmdarray[4] = "--output=" + dexFilePath; System.arraycopy(files, 0, cmdarray, 5, files.length); try { Process process = Runtime.getRuntime().exec(cmdarray, null, classesDirectory); process.waitFor(); } catch (Exception e) { throw new IllegalStateException("Compiling failed.", e); } FileInputStream in = null; try { in = new FileInputStream(dexFilePath); return IOUtils.toByteArray(in); } catch (IOException e) { throw new IllegalStateException("Loading " + dexFilePath + " failed.", e); } finally { IOUtils.closeQuietly(in); } }
From source file:org.eclim.plugin.core.command.archive.ArchiveReadCommand.java
/** * {@inheritDoc}/* w w w . jav a2 s. c o m*/ */ public String execute(CommandLine commandLine) throws Exception { InputStream in = null; OutputStream out = null; FileSystemManager fsManager = null; try { String file = commandLine.getValue(Options.FILE_OPTION); fsManager = VFS.getManager(); FileObject fileObject = fsManager.resolveFile(file); FileObject tempFile = fsManager .resolveFile(SystemUtils.JAVA_IO_TMPDIR + "/eclim/" + fileObject.getName().getPath()); // the vfs file cache isn't very intelligent, so clear it. fsManager.getFilesCache().clear(fileObject.getFileSystem()); fsManager.getFilesCache().clear(tempFile.getFileSystem()); // NOTE: FileObject.getName().getPath() does not include the drive // information. String path = tempFile.getName().getURI().substring(URI_PREFIX.length()); // account for windows uri which has an extra '/' in front of the drive // letter (file:///C:/blah/blah/blah). if (WIN_PATH.matcher(path).matches()) { path = path.substring(1); } //if(!tempFile.exists()){ tempFile.createFile(); in = fileObject.getContent().getInputStream(); out = tempFile.getContent().getOutputStream(); IOUtils.copy(in, out); new File(path).deleteOnExit(); //} return path; } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(out); } }
From source file:org.eclim.plugin.jdt.command.src.ClassPrototypeCommand.java
/** * {@inheritDoc}//from ww w. j a v a2s . co m */ public Object execute(CommandLine commandLine) throws Exception { String className = commandLine.getValue(Options.CLASSNAME_OPTION); if (!commandLine.hasOption(Options.PROJECT_OPTION) && !commandLine.hasOption(Options.FILE_OPTION)) { throw new RuntimeException(Services.getMessage("prototype.missing.argument")); } File file = new File(SystemUtils.JAVA_IO_TMPDIR + '/' + className.replace('.', '/') + ".java"); new File(FileUtils.getFullPath(file.getAbsolutePath())).mkdirs(); file.deleteOnExit(); FileWriter out = null; try { out = new FileWriter(file); if (commandLine.hasOption(Options.FILE_OPTION)) { prototype(commandLine.getValue(Options.FILE_OPTION), out); } else { String projectName = commandLine.getValue(Options.PROJECT_OPTION); IJavaProject javaProject = JavaUtils.getJavaProject(projectName); IType type = javaProject.findType(className); if (type == null) { throw new IllegalArgumentException( Services.getMessage("type.not.found", projectName, className)); } String prototype = prototype(type); out.write(prototype); } } finally { IOUtils.closeQuietly(out); } return file.getAbsolutePath(); }
From source file:org.kuali.kra.infrastructure.TestUtilities.java
License:asdf
public static File createTempDir() throws Exception { File tmpFile = File.createTempFile("wfUnitTest", ""); Assert.assertTrue(tmpFile.delete()); File tmpDir = new File(new File(SystemUtils.JAVA_IO_TMPDIR), tmpFile.getName()); Assert.assertTrue(tmpDir.mkdir());/*w w w . j ava2s. co m*/ tmpDir.deleteOnExit(); return tmpDir; }