List of usage examples for java.io File getCanonicalPath
public String getCanonicalPath() throws IOException
From source file:com.symbian.driver.core.processors.EmulatorPostProcessor.java
/** * @param lNewFile/* www.j a va 2 s . co m*/ */ public static final void restoreFile(File lNewFile) { LOGGER.info("Restoring old file: " + lNewFile); if (lNewFile.isFile()) { try { if (lNewFile.delete() && !new File(lNewFile.getCanonicalPath() + BACKUP).renameTo(lNewFile)) { LOGGER.log(Level.SEVERE, "Could not restore file: " + lNewFile.toString()); } } catch (IOException lIOException) { LOGGER.log(Level.SEVERE, "Could not restore file: " + lNewFile.toString(), lIOException); } } else { LOGGER.log(Level.WARNING, "Could not find file to restore: " + lNewFile.toString()); } }
From source file:apim.restful.exportimport.utils.ArchiveGenerator.java
/** * Zip it//w ww .j a v a2 s. co m * * @param zipFile output ZIP file location */ public static void zipIt(String zipFile, String sourceDirectory) { File directoryToZip = new File(sourceDirectory); List<File> fileList = new ArrayList<File>(); try { System.out.println("---Getting references to all files in: " + directoryToZip.getCanonicalPath()); } catch (IOException e) { e.printStackTrace(); } getAllFiles(directoryToZip, fileList); System.out.println("---Creating zip file"); writeZipFile(directoryToZip, fileList); System.out.println("---Done"); directoryToZip.delete(); if (log.isDebugEnabled()) { log.debug("hf;kljhgff"); } }
From source file:com.arcusys.liferay.vaadinplugin.util.WidgetsetUtil.java
private static void includeVaadinAddonJar(File file, List<VaadinAddonInfo> addons) { try {/*w w w.ja v a 2 s. c o m*/ URL url = new URL("file:" + file.getCanonicalPath()); url = new URL("jar:" + url.toExternalForm() + "!/"); JarURLConnection conn = (JarURLConnection) url.openConnection(); JarFile jarFile = conn.getJarFile(); if (jarFile != null) { Manifest manifest = jarFile.getManifest(); if (manifest == null) { // No manifest so this is not a Vaadin Add-on return; } Attributes attrs = manifest.getMainAttributes(); String value = attrs.getValue("Vaadin-Widgetsets"); if (value != null) { String name = attrs.getValue("Implementation-Title"); String version = attrs.getValue("Implementation-Version"); if (name == null || version == null) { // A jar file with Vaadin-Widgetsets but name or version // missing. Most probably vaadin.jar itself, skipping it // here return; } List<String> widgetsets = new ArrayList<String>(); String[] widgetsetNames = value.split(","); for (String wName : widgetsetNames) { String widgetsetname = wName.trim().intern(); if (!widgetsetname.equals("")) { widgetsets.add(widgetsetname); } } if (!widgetsets.isEmpty()) { addons.add(new VaadinAddonInfo(name, version, file, widgetsets)); } } } } catch (Exception e) { log.warn("Exception trying to include Vaadin Add-ons.", e); } }
From source file:eu.eubrazilcc.lvl.service.io.DatasetWriter.java
private static File writeGbXmlSequences(final List<File> files, final File outDir, final String compression) throws IOException { final File outFile = new File(outDir, "sequences.xml"); String outFilename = outFile.getCanonicalPath(); LOGGER.trace("Writing a bulk of NCBI sequences to '" + outFile.getCanonicalPath()); final GBSet set = GBSEQ_XML_FACTORY.createGBSet(); for (final File file : files) { final GBSeq sequence = getSequence(file); set.getGBSeq().add(sequence);//from www .java2 s . c om } outFile.getParentFile().mkdirs(); GBSEQ_XMLB.typeToFile(set, outFile); if (compression.equals(GZIP)) { outFilename = gzip(outFile.getCanonicalPath()); outFile.delete(); } return new File(outFilename); }
From source file:jp.igapyon.diary.v3.util.IgapyonV3Util.java
/** * //from w ww . jav a 2s. c om * @param titleString * like 'md2html'. * @param outputData * @param targetHtml * @return * @throws IOException */ public static boolean checkWriteNecessary(final String titleString, final String outputData, final File targetHtml) throws IOException { if (targetHtml.exists() == false) { System.out.println(titleString + ": add: " + targetHtml.getCanonicalPath()); return true; } else { final String origOutputHtmlString = IgapyonV3Util.readTextFile(targetHtml); if (outputData.equals(origOutputHtmlString)) { System.out.println(titleString + ": non: " + targetHtml.getCanonicalPath()); return false; } else { System.out.println(titleString + ": upd: " + targetHtml.getCanonicalPath()); return true; } } }
From source file:ConnectionUtil.java
/** Sets the full path of the config file to read. * @param configFileNam The FileName of the configuration file to use. *//*from w w w . ja v a 2 s .co m*/ public static void setConfigFileName(String configFileNam) { configFileName = configFileNam; File file = new File(configFileName); if (!file.canRead()) { throw new IllegalArgumentException("Unreadable: " + configFileName); } try { ConnectionUtil.configFileName = file.getCanonicalPath(); } catch (IOException ex) { System.err.println("Warning: IO error checking path: " + configFileName); ConnectionUtil.configFileName = configFileName; } }
From source file:luceneindexdemo.LuceneIndexDemo.java
public static void createIndex() throws Exception { Analyzer analyzer = new StandardAnalyzer(); boolean recreateIndexIfExists = true; IndexWriter indexWriter = new IndexWriter(INDEX_DIRECTORY, analyzer, recreateIndexIfExists); File dir = new File(FILES_TO_INDEX); File[] files = dir.listFiles(); for (File file : files) { Document document = new Document(); String path = file.getCanonicalPath(); document.add(new Field(FIELD_PATH, path, Field.Store.YES, Field.Index.UN_TOKENIZED, Field.TermVector.WITH_OFFSETS)); Reader reader = new FileReader(file); document.add(new Field(FIELD_CONTENTS, reader)); //System.out.println(document.getField(FIELD_PATH)); //System.out.println(document.hashCode()); indexWriter.addDocument(document); }/*from w ww. ja va 2 s. co m*/ indexWriter.optimize(); indexWriter.close(); }
From source file:io.apiman.test.common.util.TestUtil.java
/** * Loads a test plan from a file resource. * @param planFile/* ww w . j a v a2s. co m*/ */ public static final TestPlan loadTestPlan(File planFile) { try { if (!planFile.isFile()) throw new RuntimeException("Test Plan not found: " + planFile.getCanonicalPath()); //$NON-NLS-1$ JAXBContext jaxbContext = JAXBContext.newInstance(TestPlan.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); TestPlan plan = (TestPlan) jaxbUnmarshaller.unmarshal(planFile); return plan; } catch (Throwable e) { throw new RuntimeException(e); } }
From source file:de.micromata.genome.util.runtime.AssertUtils.java
/** * Retrieve lines.//from www . j a v a 2 s.co m * * @param fname the fname * @return the list */ private static List<String> retrieveLines(final String fname) { for (final String sp : sourcePaths) { final File d = new File(sp); // NOPMD stefan final File sf = new File(d, fname); // NOPMD stefan try { final String ss = sf.getCanonicalPath(); if (sf.exists() == false) { continue; } return getFileLines(sf); } catch (final IOException ex) { continue; } } return null; }
From source file:io.fabric8.maven.core.util.ProcessUtil.java
private static String canonicalPath(File file) { try {//from ww w. jav a 2 s. c o m return file.getCanonicalPath(); } catch (IOException e) { String absolutePath = file.getAbsolutePath(); return absolutePath; } }