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:io.github.azagniotov.stubby4j.Main.java
private static void startStubby4jUsingCommandLineArgs() { try {//ww w . j a va 2s . c om final long initialStart = System.currentTimeMillis(); final Map<String, String> commandLineArgs = commandLineInterpreter.getCommandlineParams(); final String configFilename = commandLineArgs.get(CommandLineInterpreter.OPTION_CONFIG); ANSITerminal.muteConsole(commandLineInterpreter.isMute()); ConsoleUtils.enableDebug(commandLineInterpreter.isDebug()); final File configFile = new File(configFilename); final Future<List<StubHttpLifecycle>> stubLoadComputation = EXECUTOR_SERVICE .submit(() -> new YAMLParser().parse(configFile.getParent(), configFile)); final StubbyManager stubbyManager = new StubbyManagerFactory().construct(configFile, commandLineArgs, stubLoadComputation); stubbyManager.startJetty(); final long totalEnd = System.currentTimeMillis(); ANSITerminal.status(String.format(BR + "stubby4j successfully started after %s milliseconds", (totalEnd - initialStart)) + BR); stubbyManager.statuses().forEach(ANSITerminal::status); ANSITerminal.info(BR + "Quit: ctrl-c" + BR); } catch (final Exception ex) { final String msg = String.format("Could not init stubby4j, error: %s", ex.toString()); throw new Stubby4JException(msg, ex); } }
From source file:gov.nih.nci.cacis.transform.XSLTv2TransformerTest.java
@BeforeClass public static void setupEnv() throws URISyntaxException { System.setProperty("cacis-pco.transformer.xml2rdf.xsl", "sampleXSLv2.xsl"); final File smplxsl = new File( XSLTv2TransformerTest.class.getClassLoader().getResource("xsl2/sampleXSLv2.xsl").toURI()); System.setProperty("cacis-pco.transformer.xsl.baseClassPath", smplxsl.getParent() + "/"); }
From source file:com.edgenius.core.util.ZipFileUtil.java
/** * @param destName// w ww .j a va 2 s. c om */ private static void prepareDirectory(String destName) { File destNameFile = new File(destName); String path = destNameFile.getParent(); if (path != null) { File pathDir = new File(path); pathDir.mkdirs(); } }
From source file:net.bpelunit.test.util.TestUtil.java
public static TestSuite getResults(File bpts) throws ConfigurationException, DeploymentException, SpecificationException { TestTestRunner runner = new TestTestRunner(bpts.getParent(), bpts.getName()); runner.testRun();/*from w w w .j a v a 2 s.c om*/ assertTrue("Test suites should pass all tests", runner.getTestSuite().getStatus().isPassed()); return runner.getTestSuite(); }
From source file:at.riemers.velocity2js.velocity.Velocity2Js.java
public static List<I18NBundle> getBundles(String resource) { List<I18NBundle> bundles = new ArrayList<I18NBundle>(); if (resource != null) { try {/* w w w.java 2 s.c o m*/ File rb = new File(resource); String rbDirName = rb.getParent(); String resourceName = rb.getName(); //log("[velocity2js] - " + resourceName); if (rbDirName == null) { rbDirName = "."; } File rbDir = new File(rbDirName); String[] files = rbDir.list(new PropertiesFilter(resourceName)); for (String file : files) { bundles.add(new I18NBundle(rbDirName, file)); } } catch (Exception ex) { log.error("[velocity2js] - " + ex.toString(), ex); } } else { bundles.add(new I18NBundle()); } return bundles; }
From source file:Main.java
/** * Rename existing file in same directory if target file exists, delete * Code nicked from http://stackoverflow.com/users/325442/mr-bungle * @param context// w w w .ja v a 2 s . co m * @param originalFileName * @param newFileName */ private static void rename(Context context, String originalFileName, String newFileName) { File originalFile = context.getFileStreamPath(originalFileName); if (originalFile.exists()) { Log.d("SavingHelper", "renaming " + originalFileName + " size " + originalFile.length() + " to " + newFileName); File newFile = new File(originalFile.getParent(), newFileName); if (newFile.exists()) { context.deleteFile(newFileName); } originalFile.renameTo(newFile); } }
From source file:com.netflix.nicobar.core.utils.__JDKPaths.java
static void processDirectory1(final Set<String> pathSet, final File file, final String pathBase) { for (File entry : file.listFiles()) { if (entry.isDirectory()) { processDirectory1(pathSet, entry, pathBase); } else {/*from ww w .j a v a 2 s. c o m*/ String packagePath = entry.getParent(); if (packagePath != null) { packagePath = packagePath.substring(pathBase.length()).replace('\\', '/'); if (packagePath.startsWith("/")) { packagePath = packagePath.substring(1); } pathSet.add(packagePath); } } } }
From source file:com.netflix.nicobar.core.utils.__JDKPaths.java
static void processDirectory0(final Set<String> pathSet, final File file) { for (File entry : file.listFiles()) { if (entry.isDirectory()) { processDirectory1(pathSet, entry, file.getPath()); } else {/* w w w . jav a 2 s.c om*/ final String parent = entry.getParent(); if (parent != null) pathSet.add(parent); } } }
From source file:com.taunova.app.libview.components.ImageHelpers.java
public static File addPrefixToFile(File file, String prefix) { String name = FilenameUtils.getBaseName(file.getName()); String extension = FilenameUtils.getExtension(file.getName()); StringBuilder builder = new StringBuilder(file.getParent()); builder.append(File.separator); builder.append(name);// w w w. j a va2 s . c o m builder.append(prefix); builder.append('.'); builder.append(extension); return new File(builder.toString()); }
From source file:Main.java
public static File[] getMountedVolumesAsFile() { final String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state) || Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { // we can read the External Storage... //Retrieve the primary External Storage: final File primaryExternalStorage = Environment.getExternalStorageDirectory(); //Retrieve the External Storages root directory: String externalStorageRootDir = null; if ((externalStorageRootDir = primaryExternalStorage.getParent()) == null) { // no parent... return (new File[] { primaryExternalStorage }); } else {//w ww.jav a 2 s. co m final File externalStorageRoot = new File(externalStorageRootDir); final File[] files = externalStorageRoot.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String filename) { // TODO Auto-generated method stub File file = new File(dir, filename); if (file.isDirectory() && file.canRead() && file.canWrite() && !file.isHidden()) { return true; } return false; } }); //.listFiles(); List<File> data = new ArrayList<File>(); for (final File file : files) { if (file.isDirectory() && file.canRead() && file.canWrite() && !file.isHidden() && (files.length > 0)) { // it is a real directory (not a USB drive)... if (file.toString().equals(primaryExternalStorage.toString())) data.add(file); else { if (!file.toString().contains("usb") || !file.toString().contains("USB")) { data.add(file); } } } } return data.toArray(new File[data.size()]); } } else { // we cannot read the External Storage..., return null return null; } }