List of usage examples for java.io File deleteOnExit
public void deleteOnExit()
From source file:com.android.sdklib.repository.local.LocalPlatformPkgInfoTest.java
@NonNull private static File getJsonFile(String content) throws IOException { File json = File.createTempFile("testGetLibsFromJson", ""); json.deleteOnExit(); Files.write(content, json, Charsets.UTF_8); return json;/* ww w.java 2s .c o m*/ }
From source file:Main.java
static File createTempFile(String prefix, String suffix, boolean deleteOnExit) throws IOException { final File tempFile = File.createTempFile(prefix, suffix); if (deleteOnExit) { tempFile.deleteOnExit(); }//from ww w . j ava 2s . c om return tempFile; }
From source file:de.unisb.cs.st.javalanche.mutation.util.DBPerformanceTest.java
private static void testWrite() { StopWatch stopWatch = new StopWatch(); stopWatch.start();/* w ww.j av a 2s. co m*/ try { File file = new File("test.txt"); file.deleteOnExit(); FileWriter fw = new FileWriter(file); BufferedWriter w = new BufferedWriter(fw); for (int i = 0; i < 50 * 1024 * 1024; i++) { w.append('x'); } w.close(); } catch (IOException e) { e.printStackTrace(); } stopWatch.stop(); System.out.printf("Writing file took %s\n", DurationFormatUtils.formatDurationHMS(stopWatch.getTime())); }
From source file:cop.raml.TestUtils.java
public static File createTempDir() { File file = Files.createTempDir(); file.deleteOnExit(); return file; }
From source file:cop.raml.TestUtils.java
public static File createTempDir(File parent, String name) { File file = new File(parent, name); file.deleteOnExit(); file.mkdir();/*from w ww .ja v a 2 s .co m*/ return file; }
From source file:cop.raml.TestUtils.java
public static File createTempFile(File parent, String name) throws IOException { File file = new File(parent, name); file.deleteOnExit(); FileUtils.write(file, "", Charset.forName("UTF-8")); return file;//from w w w . j a va2s .com }
From source file:com.thoughtworks.go.util.TestFileUtil.java
public static File createTestFolder(File parent, String folderName) { File subDir = new File(parent, folderName); subDir.mkdirs();//from ww w. ja v a2s .c o m subDir.deleteOnExit(); return subDir; }
From source file:com.ibm.wala.cast.js.nodejs.NodejsRequiredCoreModule.java
public static NodejsRequiredCoreModule make(String name) throws IOException { if (!names.containsKey(name)) { java.nio.file.Path p = Files.createTempDirectory("nodejs"); File f = new File(p.toFile(), name + ".js"); f.deleteOnExit(); p.toFile().deleteOnExit();/*from w w w. ja v a 2 s. co m*/ names.put(name, f); } File file = names.get(name); TemporaryFile.streamToFile(file, getModule(name)); SourceFileModule sourceFileModule = CAstCallGraphUtil.makeSourceModule(file.toURI().toURL(), file.getName()); return new NodejsRequiredCoreModule(file, sourceFileModule); }
From source file:Main.java
public static boolean saveBitmap2File(Bitmap bitmap, File file) { FileOutputStream fos = null;//from w w w . j a va 2s . c om try { file.deleteOnExit(); file.createNewFile(); fos = new FileOutputStream(file); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos); fos.flush(); } catch (IOException e) { e.printStackTrace(); return false; } finally { if (fos != null) { try { fos.close(); } catch (IOException e1) { e1.printStackTrace(); } } } return true; }
From source file:com.zb.app.common.file.FileUtils.java
public static File stream2file(InputStream in) throws IOException { final File tempFile = File.createTempFile("stream2file", ".tmp"); tempFile.deleteOnExit(); try (FileOutputStream out = new FileOutputStream(tempFile)) { IOUtils.copy(in, out);/*ww w.j a v a 2 s . c o m*/ } return tempFile; }