List of usage examples for java.io File getPath
public String getPath()
From source file:com.sldeditor.ui.detail.config.symboltype.externalgraphic.RelativePath.java
/** * Test path (Windows).//from w w w . j a va2 s . c o m * * @param path the path * @param prefixLen the prefix length * @return true, if successful */ private static boolean testPathWin(String path, int prefixLen) { if (prefixLen == 3) { return true; } File f = new File(path); if ((prefixLen == 2) && (f.getPath().charAt(0) == '/')) { return true; } return false; }
From source file:com.ts.db.connector.ConnectorDriverManager.java
private static boolean isJarFile(File file) { return isJarFile(file.getPath()); }
From source file:eu.planets_project.tb.impl.serialization.ExperimentViaJAXB.java
/** * Load an experiment from a file and add to the DB. * @param uploaded The File containing the experiment XML. * @return the ID of the new experiment. *//*w ww .ja v a 2 s . c om*/ private static long storeNewExperiment(File uploaded) { log.info("Importing experiment from file: " + uploaded.getPath()); ExperimentImpl exp = ExperimentViaJAXB.readFromFile(uploaded); log.info("Parsed into Experiment: " + exp.getExperimentSetup().getBasicProperties().getExperimentName()); return storeExperiment(exp); }
From source file:au.com.borner.salesforce.util.FileUtilities.java
public static Pair<String, SourceFileMetaData> getFileContents(File file) throws Exception { String body = FileUtils.readFileToString(file); File metadataFile = new File(file.getPath() + ".sfmd"); if (!metadataFile.exists()) { throw new IllegalStateException("Unable to find metadata file at " + metadataFile.getAbsolutePath()); }/* www. j av a 2 s.co m*/ String metadataContents = FileUtils.readFileToString(metadataFile); SourceFileMetaData metadata = new SourceFileMetaData(metadataContents); return new Pair<String, SourceFileMetaData>(body, metadata); }
From source file:Main.java
/** * Prepares the destination directory by creating directories if needed * @param destination The destination directory * @throws IOException//from w w w . j a v a 2s .c om */ public static void prepareDestination(File destination) throws IOException { File parent = destination.getParentFile(); if (!parent.exists()) { if (!parent.mkdirs()) { throw new IOException("Unable to create destination directory: " + parent.getPath()); } } }
From source file:net.orpiske.ssps.common.repository.utils.RepositoryUtils.java
private static void readPackageProperties(final File file, final PackageInfo packageInfo) { File settingsFile = new File(file.getPath() + File.separator + "package.properties"); if (logger.isDebugEnabled()) { logger.debug("Reading package properties for " + file.getPath()); logger.debug("Trying to open package.properties at " + settingsFile.getPath()); }//from www .j a va 2 s. co m if (settingsFile.exists() && settingsFile.canRead()) { PropertiesConfiguration packageSettings; try { packageSettings = new PropertiesConfiguration(settingsFile); String slot = packageSettings.getString("package.default.slot", SlotComparatorFactory.DEFAULT_SLOT); packageInfo.setSlot(slot); } catch (ConfigurationException e) { logger.warn("Unable to read package configuration file at " + settingsFile.getPath()); if (logger.isDebugEnabled()) { logger.debug(e.getMessage(), e); } } } else { packageInfo.setSlot(SlotComparatorFactory.DEFAULT_SLOT); } }
From source file:jfix.zk.Medias.java
public static File asFile(Media media) { try {//from w w w . j ava2 s.c om File directory = Files.createTempDirectory("jfix-media").toFile(); directory.deleteOnExit(); File file = new File(directory.getPath() + File.separator + media.getName()); OutputStream output = new FileOutputStream(file); if (media.isBinary()) { InputStream input = Medias.asStream(media); IOUtils.copy(input, output); input.close(); } else { Reader input = Medias.asReader(media); IOUtils.copy(input, output); input.close(); } output.close(); return file; } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:Utils.java
/** * delete all files under this file and including this file * /*from w w w . j a v a 2 s . c o m*/ * @param f * @throws IOException */ public static void deleteAll(File f) throws IOException { recurse(f, new RecurseAction() { public void doFile(File file) throws IOException { file.delete(); if (file.exists()) { throw new IOException("Failed to delete " + file.getPath()); } } public void doBeforeFile(File f) { } public void doAfterFile(File f) { } }); }
From source file:com.microsoft.alm.plugin.idea.common.setup.WindowsStartup.java
/** * Setup windows specific configurations upon plugin launch *//*w w w. ja v a2s . c om*/ public static void startup() { try { final String cmdPath = IdeaHelper.getResourcePath(WindowsStartup.class.getResource("/"), CMD_NAME, WIN_DIR); final File cmdFile = new File(cmdPath); if (cmdFile.exists() && doesKeyNeedUpdated(cmdFile)) { final File regeditFile = createRegeditFile(cmdFile); launchElevatedCreation(regeditFile.getPath()); regeditFile.delete(); } } catch (IOException e) { logger.warn("An IOException was encountered while creating/writing to the Regedit file: {}", e.getMessage()); } catch (Win32Exception e) { logger.warn("A Win32Exception was encountered while trying to get IntelliJ's registry key: {}", e.getMessage()); } catch (Exception e) { logger.warn("An exception was encountered while trying to create vsoi registry key: {}", e.getMessage()); } }
From source file:org.camunda.bpm.cockpit.test.util.DeploymentHelper.java
private static void addFiles(JavaArchive archive, String prefix, String rootPath, File dir) { for (File f : dir.listFiles()) { if (f.isFile()) { String filePath = f.getPath().replace(rootPath, "").replace("\\", "/"); archive.addAsResource(f, prefix + filePath); } else {/* w w w . j a v a 2 s .c o m*/ addFiles(archive, prefix, rootPath, f); } } }