List of usage examples for java.io File getName
public String getName()
From source file:Main.java
public static void copyIfNotExist(Context context, int ressourceId, String target) throws IOException { File lFileToCopy = new File(target); if (!lFileToCopy.exists()) { copyFromPackage(context, ressourceId, lFileToCopy.getName()); }//from ww w. j av a 2 s . c o m }
From source file:Main.java
public static void valiFileCanWrite(File file) throws IOException { if (!file.canWrite()) { throw new IOException("For file '" + file.getName() + "' not write access!"); }/*from ww w . j a v a 2 s. c o m*/ }
From source file:at.ac.tuwien.infosys.jcloudscale.datastore.util.FileUtil.java
/** * Get the file extension for a given file * * @param file given file//from w w w .ja v a2 s.c om * @return the extension of the file */ public static String getFileExtension(File file) { int i = file.getName().lastIndexOf('.'); if (i > 0) { return file.getName().substring(i + 1); } return null; }
From source file:com.vaadin.sass.testcases.scss.AbstractDirectoryScanningSassTests.java
public static Collection<String> getScssResourceNames(URL directoryUrl) throws URISyntaxException { List<String> resources = new ArrayList<String>(); for (File scssFile : getScssFiles(directoryUrl)) { resources.add(scssFile.getName()); }//from w w w . j ava 2 s .c om return resources; }
From source file:com.clothcat.hpoolauto.HtmlUploader.java
/** * Upload the html via FTP//w ww . j a v a 2s . c o m */ public static void uploadHtml() { FTPClient ftpc = new FTPClient(); FTPClientConfig conf = new FTPClientConfig(); ftpc.configure(conf); try { ftpc.connect(Constants.FTP_HOSTNAME); ftpc.login(Constants.FTP_USERNAME, Constants.FTP_PASSWORD); File dir = new File(Constants.HTML_FILEPATH); File[] files = dir.listFiles(); ftpc.changeWorkingDirectory("/htdocs"); for (File f : files) { HLogger.log(Level.FINEST, "Uploading file: " + f.getName()); FileInputStream fis = new FileInputStream(f); ftpc.storeFile(f.getName(), fis); } ftpc.logout(); } catch (IOException ioe) { ioe.printStackTrace(); } finally { if (ftpc.isConnected()) { try { ftpc.disconnect(); } catch (IOException ioe) { } } } }
From source file:com.github.lucene.store.CreateJavaTestIndex.java
private static Document getDocument(final String rootDir, final File file) throws IOException, ParseException { final String fileName = file.getName(); final String filePath = file.getAbsolutePath(); final String content = FileUtils.readFileToString(file); System.out.println(fileName + ":" + filePath + "\n---------"); final Document doc = new Document(); doc.add(new StringField("fileName", fileName, Field.Store.YES)); doc.add(new StringField("filePath", filePath, Field.Store.YES)); doc.add(new TextField("content", content, Field.Store.NO)); return doc;/*from w w w .j av a2s . c om*/ }
From source file:com.googlecode.dex2jar.util.ASMifierFileV.java
public static void doFile(File srcDex) throws IOException { doFile(srcDex, new File(srcDex.getParentFile(), srcDex.getName() + "_asmifier")); }
From source file:com.facebook.stetho.inspector.domstorage.SharedPreferencesHelper.java
public static List<String> getSharedPreferenceTags(Context context) { ArrayList<String> tags = new ArrayList<String>(); String rootPath = context.getApplicationInfo().dataDir + "/shared_prefs"; File root = new File(rootPath); if (root.exists()) { for (File file : root.listFiles()) { String fileName = file.getName(); if (fileName.endsWith(PREFS_SUFFIX)) { tags.add(fileName.substring(0, fileName.length() - PREFS_SUFFIX.length())); }//from ww w . ja va 2s .c om } } return tags; }
From source file:de.tudarmstadt.ukp.experiments.argumentation.sequence.significance.SignificanceMain.java
/** * Test significance between all methods in the folder and prints them as a CSV table * * @param mainFolder folder//from w w w . j a v a 2 s .c o m * @param folderResultPrefix prefix of folders to test, i.e. "cv_" * @throws IOException */ public static void compareMethods(File mainFolder, final String folderResultPrefix) throws IOException { File[] cvResults = mainFolder.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { return pathname.isDirectory() && pathname.getName().startsWith(folderResultPrefix); } }); Table<String, String, Boolean> table = TreeBasedTable.create(); for (int i = 0; i < cvResults.length; i++) { for (int j = 0; j < cvResults.length; j++) { if (i != j) { File one = cvResults[i]; File two = cvResults[j]; double pValue = TestSignificanceTwoFiles.compareId2OutcomeFiles( new File(one, TOKEN_LEVEL_PREDICTIONS_CSV), new File(two, TOKEN_LEVEL_PREDICTIONS_CSV), new OutcomeSuccessMapReaderSequenceTokenCSVImpl()); // order of methods does not matter List<String> methods = new ArrayList<>(); methods.add(one.getName()); methods.add(two.getName()); Collections.sort(methods); table.put(methods.get(0), methods.get(1), pValue < P_VALUE); // and make symmetric matrix table.put(methods.get(1), methods.get(0), pValue < P_VALUE); } } } System.out.println(tableToCsv(table)); }
From source file:com.runwaysdk.dataaccess.io.instance.VersioningUnzipper.java
/** * Expands the zip files and imports the terms therein. * /*from w w w . j a v a 2 s . com*/ * @param dir */ public static void processZipDir(String dir) { try { 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()) { FileUtils.deleteDirectory(outputDir); } outputDir.mkdir(); try { 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))); } } DatabaseVersioning.main(new String[] { outputDir.getAbsolutePath() }); } finally { FileUtils.deleteDirectory(outputDir); } } catch (IOException e) { throw new ProgrammingErrorException(e); } }