List of usage examples for java.io File getCanonicalPath
public String getCanonicalPath() throws IOException
From source file:ca.nines.ise.dom.DOMStream.java
/** * Constructs a DOMStream from a File. The resulting DOM source will * return the absolute path to the file. * * @param input The file to read and parse. * * @throws FileNotFoundException if the file cannot be found. * @throws IOException if the file cannot be read. *///w ww. j av a 2 s . c o m public DOMStream(File input) throws FileNotFoundException, IOException { this(new FileInputStream(input), input.getCanonicalPath()); }
From source file:io.narayana.perf.product.BarChart.java
private void writeImageData(JFreeChart chart, String imageFileName, String formatName) throws IOException { BufferedImage objBufferedImage = chart.createBufferedImage(600, 300); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(objBufferedImage, "png", baos); byte[] byteArray = baos.toByteArray(); InputStream in = new ByteArrayInputStream(byteArray); BufferedImage image = ImageIO.read(in); File outputfile = new File(imageFileName); ImageIO.write(image, formatName, outputfile); System.out.printf("GENERATED IMAGE FILE TO %s%n", outputfile.getCanonicalPath()); }
From source file:eu.openanalytics.rsb.component.DataDirectoriesResource.java
@Path("/") @GET/*ww w . j a v a2 s . c o m*/ public Directory browseRoots(@Context final HttpHeaders httpHeaders, @Context final UriInfo uriInfo) throws URISyntaxException, IOException { final Directory roots = Util.REST_OBJECT_FACTORY.createDirectory(); roots.setPath("/"); roots.setName("Remote Data"); roots.setUri(Util.buildDataDirectoryUri(httpHeaders, uriInfo, "/").toString()); roots.setEmpty(rootMap.isEmpty()); for (final Entry<String, File> rootEntry : rootMap.entrySet()) { final Directory root = Util.REST_OBJECT_FACTORY.createDirectory(); final File rootDirectory = rootEntry.getValue(); root.setPath(rootDirectory.getCanonicalPath()); root.setName(rootDirectory.getName()); root.setUri(Util.buildDataDirectoryUri(httpHeaders, uriInfo, rootEntry.getKey()).toString()); root.setEmpty(isDirectoryEmpty(rootDirectory)); roots.getDirectories().add(root); } return roots; }
From source file:com.marvelution.bamboo.plugins.sonar.tasks.AbstractSonarMavenConfig.java
/** * Get the Maven executable path from the home path of the Maven installation * //from w ww . j ava2 s . c o m * @param homePath the home path (M2_HOME) of the Maven installation * @return the path to the executable */ @NotNull protected String getMavenExecutablePath(@NotNull String homePath) { String pathToExecutable = StringUtils.join(new String[] { homePath, "bin", this.executableName }, File.separator); if (StringUtils.contains(pathToExecutable, " ")) { try { File f = new File(pathToExecutable); pathToExecutable = f.getCanonicalPath(); } catch (IOException e) { log.warn("IO Exception trying to get executable", e); } } return pathToExecutable; }
From source file:com.solace.data.BaseTest.java
@After public void tearDown() throws Exception { LOGGER.info("Stopping in-memory HSQL database."); try {/* w w w .jav a 2 s .c o m*/ cnxn.createStatement().execute("SHUTDOWN"); } catch (Exception ex) { } if (context != null) { context = null; } for (File f : files) { if (f.exists()) { LOGGER.info("deleting {}", f.getCanonicalPath()); f.delete(); } } }
From source file:AndroidUninstallStock.java
public static LinkedHashMap<String, String> getLibFromPackage(String adb, LinkedList<String> liblist, LinkedHashMap<String, String> apklist) throws IOException { LinkedHashMap<String, String> libinclude = new LinkedHashMap<String, String>(); File libget = File.createTempFile("AndroidUninstallStockLibs", null); for (Map.Entry<String, String> info : sortByValues(apklist).entrySet()) { System.out.print("* Libs in " + info.getKey() + " (" + info.getValue() + ")"); LinkedList<String> pull = run(adb, "-s", lastdevice, "pull", "\"" + info.getKey() + "\"", "\"" + libget.getCanonicalPath() + "\""); if (pull.size() > 0 && pull.get(0).indexOf("does not exist") > 0) { System.out.println(" - file not exist"); continue; }//from w w w . j av a2s .c om LinkedList<String> libinapk = getLibsInApk(libget.toPath()); if (libinapk.size() == 0) { System.out.println(" - empty"); } else { System.out.println(":"); for (String libpath : libinapk) { String libname = libpath.substring(libpath.lastIndexOf('/') + 1); boolean libfound = false; for (String lb : liblist) { if (lb.indexOf(libname) > -1) { System.out.println(libpath + " = " + lb); libinclude.put(lb, (libinclude.containsKey(libname) ? libinclude.get(libname) + ", " : "") + info.getKey()); libfound = true; } } if (!libfound) { System.out.println(libpath + " = not found"); } } } } try { libget.delete(); } catch (Exception e) { } return libinclude; }
From source file:org.cloudfoundry.runtime.CloudServicesTest.java
protected void createAndStartApp(String appName, List<String> serviceNames) throws IOException { File file = new File(TEST_APP_DIR + "/" + appName + ".war"); assertTrue("Expected test app at " + file.getCanonicalPath(), file.exists()); List<String> uris = new ArrayList<String>(); uris.add(computeAppUrl());/* ww w. j a v a 2 s . c o m*/ CloudApplication app = testAppCreator.createAndUploadTestApp(file, APP_NAME, serviceNames, uris); setTestProfile(app); client.startApplication(APP_NAME); }
From source file:com.adaptris.core.lms.LargeFsProducer.java
private void copy(FileBackedMessage msg, File t) throws Exception { File fileToWriteTo = t;/* ww w .ja v a2s . co m*/ if (getTempDirectory() != null) { File tmpFile = createTempFile(msg); log.trace("Writing to temporary file {}", tmpFile.getCanonicalPath()); fileToWriteTo = tmpFile; } try { FileUtils.copyFile(msg.currentSource(), fileToWriteTo); } catch (IOException e) { if (e.getMessage().contains("Failed to copy full contents")) { // FileUtils.copyFile uses FileChannel.transferFrom(), which has been // causing // some problems with NFS mounts, so let's just try again. // After all it's a "large file"; fileToWriteTo.delete(); FileUtils.copyFile(msg.currentSource(), fileToWriteTo); } else { throw e; } } if (getTempDirectory() != null) { log.trace("Renaming temporary file to " + t.getCanonicalPath()); fileToWriteTo.renameTo(t); } }
From source file:io.druid.java.util.common.CompressionUtils.java
/** * Unzip the pulled file to an output directory. This is only expected to work on zips with lone files, and is not intended for zips with directory structures. * * @param pulledFile The file to unzip/*w w w . j a va 2 s .com*/ * @param outDir The directory to store the contents of the file. * * @return a FileCopyResult of the files which were written to disk * * @throws IOException */ public static FileUtils.FileCopyResult unzip(final File pulledFile, final File outDir) throws IOException { if (!(outDir.exists() && outDir.isDirectory())) { throw new ISE("outDir[%s] must exist and be a directory", outDir); } log.info("Unzipping file[%s] to [%s]", pulledFile, outDir); final FileUtils.FileCopyResult result = new FileUtils.FileCopyResult(); try (final ZipFile zipFile = new ZipFile(pulledFile)) { final Enumeration<? extends ZipEntry> enumeration = zipFile.entries(); while (enumeration.hasMoreElements()) { final ZipEntry entry = enumeration.nextElement(); final File outFile = new File(outDir, entry.getName()); validateZipOutputFile(pulledFile.getCanonicalPath(), outFile, outDir); result.addFiles(FileUtils.retryCopy(new ByteSource() { @Override public InputStream openStream() throws IOException { return new BufferedInputStream(zipFile.getInputStream(entry)); } }, outFile, FileUtils.IS_EXCEPTION, DEFAULT_RETRY_COUNT).getFiles()); } } return result; }
From source file:org.icgc.dcc.metadata.client.core.MetadataClient.java
@SneakyThrows public void register(File inputDir, File outputDir, String manifestFileName) { log.info("Regisitering: inputDir: {}, outputDir: {}, manifestFileName: {}", inputDir.getCanonicalPath(), outputDir.getCanonicalPath(), manifestFileName); log.info("Reading '{}' for files...", inputDir.getCanonicalPath()); val files = readFiles(inputDir); log.info("Read {} files", formatCount(files)); val entities = register(files); val manifestWriter = new ManifestWriter(inputDir, outputDir); manifestWriter.writeManifest(manifestFileName, entities); }