List of usage examples for java.io File getPath
public String getPath()
From source file:Main.java
/** * Get APNG working directory//w w w.j a va2s . c o m * @param context Application Context * @return Reference to the working directory */ public static File getWorkingDir(Context context) { File workingDir = null; File cacheDir = context.getExternalCacheDir(); if (cacheDir == null) { cacheDir = context.getCacheDir(); } if (cacheDir != null) { workingDir = new File(String.format("%s/apng/.nomedia/", cacheDir.getPath())); if (!workingDir.exists()) { workingDir.mkdirs(); } } return workingDir; }
From source file:utilities.itext.Turnover.java
private static Image createPieChart(HashMap<String, BigDecimal> map, String title) throws Exception { DefaultPieDataset data = new DefaultPieDataset(); for (String key : map.keySet()) { data.setValue(key, map.get(key).doubleValue()); }/* ww w .j a v a 2 s.c om*/ JFreeChart pieChart = ChartFactory.createPieChart(title, data, true, false, Locale.GERMAN); // PiePlot plot = (PiePlot) pieChart.getPlot(); // plot.setLabelGenerator(null); BufferedImage pie = pieChart.createBufferedImage(500, 500); File tempPie = File.createTempFile("png", null); ImageIO.write(pie, "png", tempPie); Image img = Image.getInstance(tempPie.getPath()); return img; }
From source file:com.collaide.fileuploader.helper.TestHelper.java
private static void clean() { File index = new File(getTestCopyDir()); String[] entries = index.list(); for (String s : entries) { File currentFile = new File(index.getPath(), s); currentFile.delete();/*from w ww. j a v a 2 s . c om*/ } }
From source file:extractcode.TraversalFiles.java
public static void fileList(File inputFile, int node, ArrayList<String> path, String folderPath) { node++;/*from w w w. j ava2s .c o m*/ File[] files = inputFile.listFiles(); if (!inputFile.exists()) { System.out.println("File doesn't exist!"); } else if (inputFile.isDirectory()) { path.add(inputFile.getName()); for (File f : files) { for (int i = 0; i < node - 1; i++) { System.out.print(" "); } System.out.print("|-" + f.getPath()); String ext = FilenameUtils.getExtension(f.getName()); if (ext.equals("java")) { try { System.out.println(" => extracted"); //Get extracted file location and add it to output file name, //in order to avoid files in different folder //have the same name. String fileLocation = ""; for (String tmpPath : path) { fileLocation += "-" + tmpPath; } String outFilePath = folderPath + "/" + f.getName() + fileLocation + "-allcode.txt"; //create output file File outputFile = new File(outFilePath); if (outputFile.createNewFile()) { System.out.println("Create successful: " + outputFile.getName()); } //extract comments ExtractCode.extractCode(f, outputFile); } catch (IOException ex) { Logger.getLogger(TraversalFiles.class.getName()).log(Level.SEVERE, null, ex); } } else { System.out.println(); } fileList(f, node, path, folderPath); } path.remove(node - 1); } }
From source file:extractcomments.TraversalFiles.java
public static void fileList(File inputFile, int node, ArrayList<String> path, String folderPath) { node++;/*from w w w . j ava2s . co m*/ File[] files = inputFile.listFiles(); if (!inputFile.exists()) { System.out.println("File doesn't exist!"); } else if (inputFile.isDirectory()) { path.add(inputFile.getName()); for (File f : files) { for (int i = 0; i < node - 1; i++) { System.out.print(" "); } System.out.print("|-" + f.getPath()); String ext = FilenameUtils.getExtension(f.getName()); if (ext.equals("java")) { try { System.out.println(" => extracted"); //Get extracted file location and add it to output file name, //in order to avoid files in different folder //have the same name. String fileLocation = ""; for (String tmpPath : path) { fileLocation += "-" + tmpPath; } String outFilePath = folderPath + "/" + f.getName() + fileLocation + "-all.txt"; //create output file File outputFile = new File(outFilePath); if (outputFile.createNewFile()) { System.out.println("Create successful: " + outputFile.getName()); } //extract comments ExtractComments.extractComments(f, outputFile); } catch (IOException ex) { Logger.getLogger(TraversalFiles.class.getName()).log(Level.SEVERE, null, ex); } } else { System.out.println(" isn't a java file."); } fileList(f, node, path, folderPath); } path.remove(node - 1); } }
From source file:extractsomecomments.TraversalFiles.java
public static void fileList(File inputFile, int node, ArrayList<String> path, String folderPath) { node++;/*w w w.j av a2 s . c o m*/ File[] files = inputFile.listFiles(); if (!inputFile.exists()) { System.out.println("File doesn't exist!"); } else if (inputFile.isDirectory()) { path.add(inputFile.getName()); for (File f : files) { for (int i = 0; i < node - 1; i++) { System.out.print(" "); } System.out.print("|-" + f.getPath()); String ext = FilenameUtils.getExtension(f.getName()); if (ext.equals("java")) { try { System.out.println(" => extracted"); //Get extracted file location and add it to output file name, //in order to avoid files in different folder //have the same name. String fileLocation = ""; for (String tmpPath : path) { fileLocation += "-" + tmpPath; } String outFilePath = folderPath + "/" + f.getName() + fileLocation + "-all.txt"; //create output file File outputFile = new File(outFilePath); if (outputFile.createNewFile()) { System.out.println("Create successful: " + outputFile.getName()); } //extract comments ExtractSomeComments.extractComments(f, outputFile); } catch (IOException ex) { Logger.getLogger(TraversalFiles.class.getName()).log(Level.SEVERE, null, ex); } } else { System.out.println(); } fileList(f, node, path, folderPath); } path.remove(node - 1); } }
From source file:net.orpiske.ssps.common.repository.ProviderFactory.java
/** * Creates a new repository provider based on the information available in the * repository dir/* ww w. j a v a 2 s .c om*/ * * @param repositoryPath the path to the repository * @return A repository provider object */ public static Provider newProvider(final File repositoryPath) { RepositoryInfo repositoryInfo = new RepositoryInfo(repositoryPath.getName()); repositoryInfo.setUrl("file://" + repositoryPath.getPath()); setRepositoryCredentials(repositoryInfo); if (isGit(repositoryPath)) { return new GitProvider(repositoryInfo); } if (isSvn(repositoryPath)) { return new SvnProvider(repositoryInfo); } return null; }
From source file:brut.directory.ZipUtils.java
private static void processFolder(final File folder, final ZipOutputStream zipOutputStream, final int prefixLength) throws BrutException, IOException { for (final File file : folder.listFiles()) { if (file.isFile()) { final String cleanedPath = BrutIO.sanitizeUnknownFile(folder, file.getPath().substring(prefixLength)); final ZipEntry zipEntry = new ZipEntry(BrutIO.normalizePath(cleanedPath)); // aapt binary by default takes in parameters via -0 arsc to list extensions that shouldn't be // compressed. We will replicate that behavior final String extension = FilenameUtils.getExtension(file.getAbsolutePath()); if (mDoNotCompress != null && (mDoNotCompress.contains(extension) || mDoNotCompress.contains(zipEntry.getName()))) { zipEntry.setMethod(ZipEntry.STORED); zipEntry.setSize(file.length()); BufferedInputStream unknownFile = new BufferedInputStream(new FileInputStream(file)); CRC32 crc = BrutIO.calculateCrc(unknownFile); zipEntry.setCrc(crc.getValue()); unknownFile.close();// ww w .jav a 2 s. co m } else { zipEntry.setMethod(ZipEntry.DEFLATED); } zipOutputStream.putNextEntry(zipEntry); try (FileInputStream inputStream = new FileInputStream(file)) { IOUtils.copy(inputStream, zipOutputStream); } zipOutputStream.closeEntry(); } else if (file.isDirectory()) { processFolder(file, zipOutputStream, prefixLength); } } }
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 {/*from w w w . j av a 2s .c o m*/ final String parent = entry.getParent(); if (parent != null) pathSet.add(parent); } } }
From source file:com.liferay.nativity.test.TestDriver.java
private static void _intitializeLogging() { File file = new File("java/nativity-log4j.xml"); if (file.exists()) { DOMConfigurator.configure(file.getPath()); }// w w w . ja v a 2 s . c om }