List of usage examples for java.io File getParent
public String getParent()
null
if this pathname does not name a parent directory. From source file:ch.kostceco.tools.siardval.service.impl.ConfigurationServiceImpl.java
private XMLConfiguration getConfig() { if (this.config == null) { try {// w w w.j a v a 2 s.c om String path = "configuration/SIARDVal.conf.xml"; URL locationOfJar = SIARDVal.class.getProtectionDomain().getCodeSource().getLocation(); String locationOfJarPath = locationOfJar.getPath(); if (locationOfJarPath.endsWith(".jar")) { File file = new File(locationOfJarPath); String fileParent = file.getParent(); path = fileParent + "/" + path; } config = new XMLConfiguration(path); } catch (ConfigurationException e) { LOGGER.logInfo(getTextResourceService().getText(MESSAGE_CONFIGURATION_ERROR_1)); // Das Konfigurations-File konnte nicht gelesen werden. LOGGER.logInfo(getTextResourceService().getText(MESSAGE_CONFIGURATION_ERROR_2)); // Im gleichen Verzeichnis wie das ".jar"-File muss sich ein // Ordner namens "configuration" befinden. LOGGER.logInfo(getTextResourceService().getText(MESSAGE_CONFIGURATION_ERROR_3)); // Im configuration-Ordner wiederum muss die Konfigurationsdatei // "SIARDVal.conf.xml" liegen. System.exit(1); } } return config; }
From source file:edu.utah.further.core.util.io.ResourceCopier.java
/** * Copy to <code>import.sql</code>. *///from www . j a v a 2 s. c o m @PostConstruct protected void afterPropertiesSet() { Validate.notNull(sourceResource, "A source resource must be specified"); Validate.notNull(targetFileName, "A target resource must be specified"); try { final File sourceFile = sourceResource.getFile(); final File newImportFile = new File(sourceFile.getParent(), "import.sql"); FileCopyUtils.copy(sourceFile, newImportFile); } catch (final IOException e) { throw new BeanInitializationException("Could not copy resource " + sourceResource, e); } }
From source file:com.cip.crane.agent.utils.FileExtractUtilsTest.java
public void TestUnzip() { String path = getAbsolutePath("extract/test.zip"); File file = new File(path); try {/*from ww w . ja v a 2 s. com*/ FileExtractUtils.unZip(file); File testFile1 = new File(file.getParent() + "/test/test1.txt"); assertTrue(testFile1.exists()); FileUtils.deleteDirectory(new File(file.getParent() + "/test")); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.coolstore.common.SLog.java
/** * create the Directory from the path//from w w w . j ava2s.c o m * * @param path */ private static void createLogDir(String path) { if (TextUtils.isEmpty(path)) { android.util.Log.e("Error", "The path is not valid."); return; } File file = new File(path); boolean ret; boolean exist; exist = file.getParentFile().exists(); if (!exist) { ret = file.getParentFile().mkdirs(); if (!ret) { android.util.Log.e("Error", "The Log Dir can not be created!"); return; } android.util.Log.i("Success", "The Log Dir was successfully created! -" + file.getParent()); } }
From source file:com.photon.phresco.framework.param.impl.DynamicallyFetchDependencyJarsImpl.java
private StringBuilder getDependencyJarPath(String rootModulePath, String subModuleName) throws PhrescoException { File pomLoc = Utility.getPomFileLocation(rootModulePath, subModuleName); StringBuilder builder = new StringBuilder(pomLoc.getParent()); builder.append(File.separator); builder.append("do_not_checkin"); builder.append(File.separator); builder.append("dependencyJars"); return builder; }
From source file:game.com.ManageFileServlet.java
private List<String> getAllFolder(String path) { List<String> gallery = new ArrayList(); File folder = new File(path); if (StringUtils.isNotBlank(path) && folder.getParent() != null && folder.getParent().contains(AppConfig.OPENSHIFT_DATA_DIR)) { gallery.add(folder.getParentFile().getAbsolutePath()); }/* ww w . j av a 2s .c o m*/ if (!folder.exists()) { return gallery; } else { gallery.add(folder.getAbsolutePath()); } if (folder.listFiles() == null) { return gallery; } for (File file : folder.listFiles()) { if (file.isDirectory()) { gallery.add(file.getAbsolutePath()); } } return gallery; }
From source file:com.dp.bigdata.taurus.agent.utils.FileExtractUtilsTest.java
@Test public void TestUnzip() { String path = getAbsolutePath("extract/test.zip"); File file = new File(path); try {/*from w w w.j a va2s . com*/ FileExtractUtils.unZip(file); File testFile1 = new File(file.getParent() + "/test/test1.txt"); assertTrue(testFile1.exists()); FileUtils.deleteDirectory(new File(file.getParent() + "/test")); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.galenframework.javascript.GalenJsExecutor.java
public Object eval(Reader scriptFileReader, String javascriptPath) throws IOException { File file = new File(javascriptPath); loadFunction.putContextPath(file.getParent()); return context.evaluateReader(scope, scriptFileReader, javascriptPath, 1, null); }
From source file:facebook4j.internal.http.MockHttpClientWrapper.java
private void registerMockJSON(String json) throws IOException { String baseDir = System.getProperty("user.dir"); if (!baseDir.endsWith("/facebook4j-core")) { baseDir += "/facebook4j-core"; }/* w ww. j a v a 2 s.c o m*/ File file = new File(baseDir + "/src/test/resources/" + mockJSONResourceName); new File(file.getParent()).mkdirs(); FileWriter writer = new FileWriter(file); writer.write(json); writer.close(); }
From source file:ijfx.core.overlay.io.OverlayIOService.java
public default File getOverlayFileFromImageFile(File imageFile) { String nameWithoutExtension = imageFile.getName().replaceAll("\\.[\\w\\d]+$", ""); return new File(imageFile.getParent(), nameWithoutExtension + OVERLAY_FILE_EXTENSION); }