List of usage examples for java.io File deleteOnExit
public void deleteOnExit()
From source file:com.sap.prd.mobile.ios.mios.StraightForwardLibAndAppWithoutSigningTest.java
@BeforeClass public static void __setup() throws Exception { dynamicVersion = "1.0." + String.valueOf(System.currentTimeMillis()); myLibArtifactFilePrefix = TestConstants.GROUP_ID_WITH_SLASH + "/MyLibrary/" + dynamicVersion + "/MyLibrary-" + dynamicVersion;/* w ww . j a va 2s .c om*/ testName = StraightForwardLibAndAppWithoutSigningTest.class.getName() + File.separator + Thread.currentThread().getStackTrace()[1].getMethodName(); remoteRepositoryDirectory = getRemoteRepositoryDirectory( StraightForwardLibAndAppWithoutSigningTest.class.getName()); prepareRemoteRepository(remoteRepositoryDirectory); Properties pomReplacements = new Properties(); pomReplacements.setProperty(PROP_NAME_DEPLOY_REPO_DIR, remoteRepositoryDirectory.getAbsolutePath()); pomReplacements.setProperty(PROP_NAME_DYNAMIC_VERSION, dynamicVersion); Map<String, String> additionalSystemProperties = new HashMap<String, String>(); additionalSystemProperties.put("mios.ota-service.url", "http://apple-ota.wdf.sap.corp:8080/ota-service/HTML"); additionalSystemProperties.put("xcode.app.defaultConfigurations", "Release"); additionalSystemProperties.put("xcode.app.defaultSdks", "iphoneos"); additionalSystemProperties.put("archive.dir", "archive"); additionalSystemProperties.put("xcode.useSymbolicLinks", Boolean.TRUE.toString()); test(testName, new File(getTestRootDirectory(), "straight-forward/MyLibrary"), "deploy", THE_EMPTY_LIST, THE_EMPTY_MAP, pomReplacements, new NullProjectModifier()); List<String> commandLineArgs = new ArrayList<String>(); commandLineArgs.add("-Dxcode.codeSigningRequired=false"); commandLineArgs.add("-Dxcode.codeSignIdentity=\"\""); appVerifier = test(testName, new File(getTestRootDirectory(), "straight-forward/MyApp"), "deploy", commandLineArgs, additionalSystemProperties, pomReplacements, new NullProjectModifier()); myAppVersionRepoDir = TestConstants.GROUP_ID_WITH_SLASH + "/MyApp/" + dynamicVersion; myAppArtifactFilePrefix = myAppVersionRepoDir + "/MyApp-" + dynamicVersion; final File tmpFolder = new File(getTargetDirectory(), "tests/tmp"); tmpFolder.deleteOnExit(); extractedIpaFolder = new File(tmpFolder, "ipa"); extractFileWithShellScript( new File(remoteRepositoryDirectory, myAppArtifactFilePrefix + "-Release-iphoneos.ipa"), extractedIpaFolder); File appstoreUploadFile = new File(remoteRepositoryDirectory, myAppArtifactFilePrefix + "-Release-iphoneos-app.zip"); assertTrue(appstoreUploadFile.exists()); appstoreFolder = new File(tmpFolder, "appstoreFolder"); appstoreFolder.deleteOnExit(); extractFileWithShellScript(appstoreUploadFile, appstoreFolder); appTestBaseDir = new File(appVerifier.getBasedir()); archiveArtifactsDir = new File(appTestBaseDir, "archive/artifacts/com.sap.ondevice.production.ios.tests/MyApp"); }
From source file:com.lxht.emos.data.cache.intf.HessianUtil.java
/** * ??,?,?????.//from w ww.j a v a2s . c o m * * @param objectFileDirectory ? * @param fileName ??????? * @return boolean ??, true:?,false:. */ public static boolean removeSerializeLikeFile(String objectFileDirectory, final String fileName) { if (StringUtils.isBlank(objectFileDirectory) || StringUtils.isBlank(fileName)) { return false; } // ?File. File objDirFile = getObjectFileDir(objectFileDirectory); // ???? File[] objFiles = objDirFile.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { if (StringUtils.isBlank(name)) { return false; } /** * ??. */ return StringUtils.startsWith(name, fileName); } }); if (ArrayUtils.isEmpty(objFiles)) { return false; } // ?. for (File file : objFiles) { boolean isDelSuc = file.delete(); if (!isDelSuc) { file.deleteOnExit(); logger.warn("removeSerializeLikeFile(),Delete the local cache file failed.[File:" + file + "]"); continue; } } return true; }
From source file:com.change_vision.astah.extension.plugin.cplusreverse.reverser.DoxygenXmlParser.java
private static String getTempAstahModelPath() throws IOException { Calendar cal = Calendar.getInstance(); String year = Integer.toString(cal.get(Calendar.YEAR)); String month = Integer.toString(cal.get(Calendar.MONTH) + 1); String day = Integer.toString(cal.get(Calendar.DATE)); String hour = Integer.toString(cal.get(Calendar.HOUR_OF_DAY)); String minute = Integer.toString(cal.get(Calendar.MINUTE)); String second = Integer.toString(cal.get(Calendar.SECOND)); String tempFileName = year + month + day + hour + minute + second; File tempFile = File.createTempFile(tempFileName, ".asta"); tempFile.deleteOnExit(); return tempFile.getAbsolutePath(); }
From source file:io.swagger.inflector.config.Configuration.java
private static void createSwaggerFile() throws IOException { InputStream in = Configuration.class.getResourceAsStream("/swagger.yaml"); File file = new File("swagger.yaml"); FileUtils.copyInputStreamToFile(in, file); file.deleteOnExit(); }
From source file:io.swagger.inflector.config.Configuration.java
private static File createInflectorFile() throws IOException { InputStream in = Configuration.class.getResourceAsStream("/inflector.yaml"); File file = new File("inflector.yaml"); FileUtils.copyInputStreamToFile(in, file); file.deleteOnExit(); return file;// ww w .ja v a 2s . c om }
From source file:dotplugin.GraphViz.java
private static File execute(final InputStream input, String format) throws CoreException { MultiStatus status = new MultiStatus(Activator.ID, 0, "Errors occurred while running Graphviz", null); // we keep the input in memory so we can include it in error messages ByteArrayOutputStream dotContents = new ByteArrayOutputStream(); File dotInput = null, dotOutput = null; try {// w ww . j a v a 2 s . c o m // determine the temp input and output locations dotInput = File.createTempFile(TMP_FILE_PREFIX, DOT_EXTENSION); dotOutput = File.createTempFile(TMP_FILE_PREFIX, "." + format); dotInput.deleteOnExit(); dotOutput.deleteOnExit(); FileOutputStream tmpDotInputStream = null; try { IOUtils.copy(input, dotContents); tmpDotInputStream = new FileOutputStream(dotInput); IOUtils.copy(new ByteArrayInputStream(dotContents.toByteArray()), tmpDotInputStream); } finally { IOUtils.closeQuietly(tmpDotInputStream); } IStatus result = runDot(format, dotInput, dotOutput); status.add(result); // status.add(logInput(dotContents)); if (!result.isOK()) LogUtils.log(status); return dotOutput; } catch (SWTException e) { status.add(new Status(IStatus.ERROR, Activator.ID, "", e)); } catch (IOException e) { status.add(new Status(IStatus.ERROR, Activator.ID, "", e)); } throw new CoreException(status); }
From source file:gdv.xport.util.AbstractFormatterTest.java
/** * Verwendet {@link AbstractFormatter#notice(gdv.xport.satz.Satz)} fuer * den Export und ueberprueft das Ergebnis mit einer bereits exportierten * Datei.//ww w. jav a 2 s . c o m * * @param formatter the formatter * @param filename the filename * @throws IOException falls was schiefgelaufen ist */ protected static void checkNotice(final AbstractFormatter formatter, final String filename) throws IOException { File output = File.createTempFile("test-notice", ".export"); Writer writer = new OutputStreamWriter(new FileOutputStream(output), "ISO-8859-1"); formatter.setWriter(writer); try { exportMusterdatei(formatter); log.info("Musterdatei was exported to " + output); } finally { writer.close(); output.deleteOnExit(); } File exported = new File("target/site", filename); if (exported.exists()) { log.info(output + " will be compared with already generated " + exported); FileTester.assertContentEquals(exported, output, Charset.forName("ISO-8859-1"), Pattern.compile("<!--.*-->")); } }
From source file:com.asakusafw.runtime.windows.WinUtilsInstaller.java
/** * Installs {@code winutils.exe} into the target directory. * @param directory the target directory * @return installed location (never null) * @throws IOException if error occurred while installing *///w w w.j ava2 s .c o m public static File put(File directory) throws IOException { TemporaryFileInstaller installer = prepare(); assert installer != null; // install into the default location File file = new File(directory, TARGET_PREFIX + TARGET_SUFFIX); try { LOG.info(MessageFormat.format("installing winutils.exe into default location: {0}", //$NON-NLS-1$ file)); installer.install(file, true); return file; } catch (IOException e) { LOG.debug(MessageFormat.format("failed to install winutils into the default location: {0}", file), e); } // install into a temporary location File temp = null; boolean success = false; try { temp = File.createTempFile(TARGET_PREFIX + '-', TARGET_SUFFIX, directory); LOG.info(MessageFormat.format("installing winutils.exe into temporary location: {0}", temp)); installer.install(temp, false); temp.deleteOnExit(); success = true; return temp; } catch (IOException e) { LOG.debug(MessageFormat.format("failed to install winutils into a temporary location: {0}", //$NON-NLS-1$ temp), e); } finally { if (success == false) { if (temp != null && temp.delete() == false) { LOG.warn(MessageFormat.format("failed to delete a temporary file: {0}", //$NON-NLS-1$ temp)); } } } throw new IOException(MessageFormat.format("error occurred while installing winutils: {0}", //$NON-NLS-1$ file)); }
From source file:com.tascape.qa.th.Utils.java
public static void deleteFileAfterMinutes(final File file, final int minutes) { file.deleteOnExit(); Thread t = new Thread() { @Override//from w w w . j a v a2 s. c o m public void run() { try { Thread.sleep(minutes * 60000); FileUtils.deleteQuietly(file); } catch (InterruptedException ex) { LOG.trace(ex.getMessage()); } } }; t.setDaemon(true); t.start(); }
From source file:io.joynr.util.JoynrUtil.java
public static File createDir(String dirName) { File tempDir = new File(dirName); if (tempDir.exists() == false) { if (!tempDir.mkdirs()) { logger.debug("Creating of dir " + dirName + " failed."); }/*from w w w . j ava 2 s . c o m*/ } tempDir.deleteOnExit(); return tempDir; }