List of usage examples for java.io File getName
public String getName()
From source file:com.schnobosoft.semeval.cortical.PrintCorrelations.java
private static void saveCorrelations(File inputFile) throws IOException { assert inputFile.getName().startsWith(INPUT_FILE_PREFIX); File gsFile = new File(inputFile.getCanonicalPath().replace(INPUT_FILE_PREFIX, GS_FILE_PREFIX)); List<Optional> gs = readScoresFile(gsFile); File targetFile = new File(inputFile.getCanonicalPath() + ".cortical.scores"); BufferedWriter writer = new BufferedWriter(new FileWriter(targetFile)); LOG.info("Writing scores to " + targetFile); for (Retina retinaName : Retina.values()) { for (Measure correlationMeasure : Measure.values()) { File outputFile = getOutputFile(inputFile, correlationMeasure, retinaName); if (outputFile.exists()) { List<Optional> scores = readScoresFile(outputFile); double pearson = getPearson(gs, scores); writer.write(String.format("Pearson correlation (%s, %s):\t%.4f%n", retinaName.name().toLowerCase(), correlationMeasure, pearson)); } else { LOG.warn("Output file not found: " + outputFile); }/*from w w w . j a v a2 s . c o m*/ } } writer.close(); }
From source file:com.googlecode.jsonschema2pojo.cli.Jsonschema2Pojo.java
private static String getNodeName(File file) { return substringBeforeLast(file.getName(), "."); }
From source file:com.milaboratory.core.io.CompressionType.java
public static CompressionType detectCompressionType(File file) { return detectCompressionType(file.getName()); }
From source file:cu.uci.uengine.utils.RegexUtils.java
public static int getDataSetNumber(File file) throws InvalidDataSetNameException { String baseName = FilenameUtils.getBaseName(file.getName()); Pattern p = Pattern.compile("\\d+$");//Digits at string end. Matcher m = p.matcher(baseName); if (!m.find()) { throw new InvalidDataSetNameException(String.format("DataSet %s is not a valid name.", baseName)); }//from w ww. j a v a2 s. co m int dataSetNumber = Integer.parseInt(m.group()); return dataSetNumber; }
From source file:net.estinet.gFeatures.Feature.FusionPlay.GameUtil.WorldUtil.java
public static void copyWorld(File f) { Bukkit.getLogger().info("[FusionPlay] Loading world " + f.getName() + "..."); File fz = new File("./world"); fz.delete();/* w w w. j a va 2s. c om*/ try { FileUtils.copyDirectory(f, fz); Bukkit.getLogger().info("[FusionPlay] World loading completed."); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.denimgroup.threadfix.framework.impl.dotNetWebForm.AscxFileMappingsFileParser.java
public static Map<String, AscxFile> getMap(File rootDirectory) { if (!rootDirectory.exists() || !rootDirectory.isDirectory()) { throw new IllegalArgumentException( "Invalid directory passed to WebFormsEndpointGenerator: " + rootDirectory); }//from w ww . j a v a 2s .c om Collection ascxFiles = FileUtils.listFiles(rootDirectory, new FileExtensionFileFilter("ascx"), TrueFileFilter.INSTANCE); Map<String, AscxFile> map = map(); for (Object aspxFile : ascxFiles) { if (aspxFile instanceof File) { File file = (File) aspxFile; String name = file.getName(); String key = name.contains(".") ? name.substring(0, name.indexOf('.')) : name; map.put(key, new AscxFile(file)); } } return map; }
From source file:com.ruesga.rview.TestUtils.java
public static File getRootDirectory() { File test = new File("").getAbsoluteFile(); if (test.getName().equals("rview")) { return test; }/*w w w . jav a2s. c o m*/ if (test.getName().equals("app")) { return test.getParentFile(); } return test; }
From source file:com.runwaysdk.dataaccess.io.instance.InstanceImporterUnzipper.java
/** * Expands the zip files and imports the terms therein. * /*from w w w. j av a 2 s . c om*/ * @param dir */ public static void processZipDir(String dir) { File directory = new File(dir); if (!directory.exists()) { logger.error("Directory [" + directory.getAbsolutePath() + "] does not exist, aborting import."); return; } final File outputDir = new File(dir + TEMP_DIR); if (outputDir.exists()) { try { FileUtils.deleteDirectory(outputDir); } catch (IOException e) { throw new RuntimeException(e); // I hate checked exceptions } } outputDir.mkdir(); for (File zip : directory.listFiles()) { if (zip.getName().endsWith(".gz")) { logger.info("Unzipping " + zip.getAbsolutePath() + " to " + outputDir + "."); FileIO.gunzip(zip, new File(outputDir, zip.getName().substring(0, zip.getName().length() - 3))); } } // InstanceImporter.runImport(outputDir, (String)null, new // DefaultConflictResolver()); importXmlFiles(outputDir); // Versioning.main(new String[]{outputDir.getAbsolutePath()}); }
From source file:hrider.io.FileHelper.java
public static void delete(File path, String... exclude) { List<String> excludedPaths = Arrays.asList(exclude); File[] files = path.listFiles(); if (files != null) { for (File file : files) { if (!excludedPaths.contains(file.getName())) { if (file.isDirectory()) { delete(file);//from www .j ava 2s . c o m } file.delete(); } } } }
From source file:iaj.linkit.App.java
private static void handleFiles(final boolean recurse, final File... listFiles) { for (File f : listFiles) { if (f.getName().endsWith(EXTENSION_WEBLOC)) { handlePlist(f);/*from w w w . j ava 2 s. c o m*/ } else if (f.getName().endsWith(EXTENSION_URL)) { handleIni(f); } else if (f.getName().endsWith(EXTENSION_URL.toLowerCase())) { handleIni(f); } else if (f.getName().endsWith(EXTENSION_DESKTOP)) { handleIni(f); } else if (recurse && f.isDirectory() && !f.isHidden()) { handleFiles(recurse, f.listFiles()); } } }