List of usage examples for java.io File createTempFile
public static File createTempFile(String prefix, String suffix) throws IOException
From source file:cdr.forms.DepositFileEditor.java
public void setValue(Object value) { if (value instanceof MultipartFile) { MultipartFile multipartFile = (MultipartFile) value; if (multipartFile.getOriginalFilename().length() == 0) { super.setValue(null); return; }//ww w . java 2 s . c o m try { File temp = File.createTempFile("temp", ".tmp"); multipartFile.transferTo(temp); DepositFile depositFile = new DepositFile(); depositFile.setFile(temp); depositFile.setFilename(multipartFile.getOriginalFilename()); depositFile.setContentType(multipartFile.getContentType()); depositFile.setSize(multipartFile.getSize()); super.setValue(depositFile); } catch (IOException e) { throw new IllegalArgumentException(e); } } else if (value instanceof DepositFile) { super.setValue(value); } else { super.setValue(null); } }
From source file:hu.bme.mit.incqueryd.engine.util.EObjectSerializer.java
public static File createTempFile() throws IOException { final File tempFile = File.createTempFile("temp-", ".json"); tempFile.deleteOnExit();/*w ww. j av a2s .c om*/ return tempFile; }
From source file:org.apache.heron.uploader.http.HttpUploaderTest.java
@BeforeClass public static void setUpClass() throws IOException { tempFile = File.createTempFile("test_topology", ".tar.gz"); }
From source file:eu.scape_project.tool.toolwrapper.core.utils.Utils.java
/** * Method useful to create a temporary directory identified by a given name * //from w ww.j a v a2 s . c o m * @param name * name of the temporary directory to be created * @return the {@link File} object that identifies the created temporary * directory or null if any exception occurs * */ public static File createTemporaryDirectory(String name) { File tempDir = null; try { tempDir = File.createTempFile(name, ""); if (!(tempDir.delete() && tempDir.mkdir())) { tempDir = null; log.error("Error creating temp folder"); } } catch (IOException e) { log.error("Error while creating temporary folder (\"" + name + "\")"); } return tempDir; }
From source file:com.mtgi.io.RelocatableFileTest.java
@Before public void setUp() throws IOException { source = File.createTempFile("RelocatableFileTest", ".tmp"); inst = new RelocatableFile(source); buffer = new ByteArrayOutputStream(); output = new ObjectOutputStream(buffer); }
From source file:com.galenframework.tests.utils.GalenUtilsTest.java
@Test public void shouldReadFile() throws Exception { File testFile = File.createTempFile("testFile", ".txt"); InputStream fileStream = GalenUtils.findFileOrResourceAsStream(testFile.getAbsolutePath()); assertThat(fileStream, notNullValue()); FileUtils.deleteQuietly(testFile);/*ww w. j av a 2 s.com*/ }
From source file:eu.ggnet.dwoss.util.ImageFinder.java
public ImageFinder(String filePath) { this.path = filePath == null ? null : new File(filePath); //Setup the error URL try {// w w w .j ava 2s . com File errorFile = File.createTempFile("error", ".png"); errorFile.deleteOnExit(); FileUtils.copyInputStreamToFile(getClass().getResourceAsStream("error.png"), errorFile); errorUrl = errorFile.toURI().toURL(); } catch (IOException ex) { throw new RuntimeException("Error in activating Fallback mode.", ex); } // The No Image. try { File noimageFile = File.createTempFile("noimage", ".png"); noimageFile.deleteOnExit(); FileUtils.copyInputStreamToFile(getClass().getResourceAsStream("noimage.png"), noimageFile); noimageUrl = noimageFile.toURI().toURL(); } catch (IOException ex) { throw new RuntimeException("Error in creating the noimgae", ex); } }
From source file:hudson.gridmaven.settings.SettingsProviderUtils.java
/** * @return a temp file which must be deleted after use *//*w ww . j av a 2 s. c o m*/ public static File copyConfigContentToFile(SettingConfig config) throws IOException { File tmpContentFile = File.createTempFile("config", "tmp"); FileUtils.writeStringToFile(tmpContentFile, config.content); return tmpContentFile; }
From source file:org.datagator.api.client.SpooledRowBuffer.java
public SpooledRowBuffer(int cacheLimit) throws IOException { this.cache = new ArrayList<Object[]>(); File tempFile = File.createTempFile("dg_Cache_", ".tmp"); tempFile.deleteOnExit();//from w w w. ja va2 s . c om this.cacheFile = new RandomAccessFile(tempFile, "rw"); this.cacheLimit = cacheLimit; }
From source file:com.legstar.protobuf.cobol.ProtoCobolUtilsTest.java
public void testExtractPackageNameFromProtoFile() throws Exception { File protoFile = File.createTempFile(getName(), ".proto"); protoFile.deleteOnExit();//w w w.ja va 2s. co m FileUtils.writeStringToFile(protoFile, "option java_package = \"com.example.tutorial\";"); ProtoFileJavaProperties javaProperties = ProtoCobolUtils.getJavaProperties(protoFile); assertEquals("com.example.tutorial", javaProperties.getJavaPackageName()); }