Example usage for java.io File getPath

List of usage examples for java.io File getPath

Introduction

In this page you can find the example usage for java.io File getPath.

Prototype

public String getPath() 

Source Link

Document

Converts this abstract pathname into a pathname string.

Usage

From source file:key.secretkey.utils.PasswordStorage.java

/**
 * Gets the .gpg files in a directory/*from  w w w.  j a  va2s .  c  om*/
 * @param path the directory path
 * @return the list of gpg files in that directory
 */
public static ArrayList<File> getFilesList(File path) {
    if (!path.exists())
        return new ArrayList<File>();

    Log.d("REPO", "current path: " + path.getPath());
    ArrayList<File> files = new ArrayList<File>(
            Arrays.asList(path.listFiles((FileFilter) FileFilterUtils.directoryFileFilter())));
    files.addAll(new ArrayList<File>((List<File>) FileUtils.listFiles(path, new String[] { "gpg" }, false)));

    return new ArrayList<File>(files);
}

From source file:MainWindowLogic.java

static void readPointsFile(File fil_hndl, JTable tabela) throws IOException, InvalidFormatInFileException {
    ReadPointsFromFile pointsReader = new ReadPointsFromFile(fil_hndl.getPath());
    System.out.println("cieka wcztytywanego pliku: " + fil_hndl.getPath());
    Point2D[] readed = pointsReader.readPoints();

    DefaultTableModel defaultModelTabeli = (DefaultTableModel) tabela.getModel();

    for (Point2D point : readed) {
        defaultModelTabeli.addRow(/*from w  w  w .  j ava  2 s  .  co m*/
                new Object[] { defaultModelTabeli.getRowCount() + 1 + ".", point.getX(), point.getY(), false });
    }

}

From source file:com.addbean.autils.tools.OtherUtils.java

public static long getAvailableSpace(File dir) {
    try {//from  w ww.j  a  v a  2  s.  c om
        final StatFs stats = new StatFs(dir.getPath());
        return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
    } catch (Throwable e) {
        return -1;
    }

}

From source file:de.tudarmstadt.ukp.dkpro.core.api.resources.CompressionUtilsTest.java

private static void testCompression(CompressionMethod compressionMethod) throws IOException {
    String text = StringUtils.repeat("This is a test. ", 100000);

    File file = new File("compressed" + compressionMethod.getExtension());

    OutputStream os = CompressionUtils.getOutputStream(file);
    os.write(text.getBytes());//w  ww .j  a va2  s.  c o m
    os.close();
    InputStream is = CompressionUtils.getInputStream(file.getPath(), new FileInputStream(file));
    assertEquals(text, IOUtils.toString(is));
    is.close();
    file.delete();
}

From source file:net.tatans.rhea.network.view.OtherUtils.java

public static long getAvailableSpace(File dir) {
    try {/* w w w .ja  v  a2  s .  com*/
        final StatFs stats = new StatFs(dir.getPath());
        return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
    } catch (Throwable e) {
        TatansLogUtils.e(e.getMessage(), e);
        return -1;
    }

}

From source file:com.microsoft.azuretools.hdinsight.util.HDInsightJobViewUtils.java

private static void extractJobViewResource() {
    URL url = HDInsightJobViewUtils.class.getResource("/resources/" + HTML_ZIP_FILE_NAME);
    URL hdinsightJobViewJarUrl = HDInsightJobViewUtils.class
            .getResource("/resources/" + HDINSIGHT_JOB_VIEW_JAR_NAME);
    if (url == null || hdinsightJobViewJarUrl == null) {
        DefaultLoader.getUIHelper().showError("Cann't find Spark job view resources", "Job view");
        return;/*from w w  w  . ja va2  s  .c  om*/
    }
    File indexRootFile = new File(PluginUtil.pluginFolder, HDINSIGIHT_FOLDER_NAME);
    if (indexRootFile.exists()) {
        FileUtils.deleteQuietly(indexRootFile);
    }
    File htmlRootFile = new File(indexRootFile.getPath(), "html");
    htmlRootFile.mkdirs();
    File htmlToFile = new File(htmlRootFile.getAbsolutePath(), HTML_ZIP_FILE_NAME);
    File hdinsightJobViewToFile = new File(indexRootFile, HDINSIGHT_JOB_VIEW_JAR_NAME);
    try {
        FileUtils.copyURLToFile(url, htmlToFile);
        FileUtils.copyURLToFile(hdinsightJobViewJarUrl, hdinsightJobViewToFile);
        HDInsightJobViewUtils.unzip(htmlToFile.getAbsolutePath(), htmlToFile.getParent());
        DefaultLoader.getIdeHelper().setProperty(HDINSIGHT_JOBVIEW_EXTRACT_FLAG, "true");
    } catch (IOException e) {
        DefaultLoader.getUIHelper().showError("Extract Job View Folder error:" + e.getMessage(), "Job view");
    }
}

From source file:com.spidasoftware.EclipseFormatter.Formatter.java

/**
 * Format by using the extension of the file.
 *
 * @param file File that will be formatted
 * @param cmd The list of command line arguments
 * @return a String that represents the name of the backup file created, null otherwise.
 *///from  ww w  .  j  ava  2 s  .co m
public static String formatUsingExtension(File file, CommandLine cmd) {
    String fileName = file.getPath();
    String extension = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length());
    String nameWithDate = null;
    String code = null;
    if (extension.equals("java") && javaFormatting(cmd)) {
        code = readInFile(fileName);
        Format javaFormatter = new JavaFormat();
        javaFormatter.format(fileName, code);
        if (javaFormatter.isFormatted() && cmd.hasOption("b"))
            nameWithDate = createBackupFile(fileName, code);

    } else if ((extension.equals("groovy")) && groovyFormatting(cmd)) {
        code = readInFile(fileName);
        Format groovyFormatter = new GroovyFormat();
        groovyFormatter.format(fileName, code);
        if (groovyFormatter.isFormatted() && cmd.hasOption("b"))
            nameWithDate = createBackupFile(fileName, code);

    } else {
        //log.info("Sorry, no formatting could be applied to " + fileName);
    }
    return nameWithDate;
}

From source file:edu.unc.lib.dl.util.ZipFileUtil.java

/**
 * Create a temporary directory, unzip the contents of the given zip file to
 * it, and return the directory.// w  w  w. ja  v a  2s.  c om
 * 
 * If anything goes wrong during this process, clean up the temporary
 * directory and throw an exception.
 */
public static File unzipToTemp(File zipFile) throws IOException {
    // get a temporary directory to work with
    File tempDir = File.createTempFile("ingest", null);
    tempDir.delete();
    tempDir.mkdir();
    tempDir.deleteOnExit();
    log.info("Unzipping to temporary directory: " + tempDir.getPath());
    try {
        unzip(new FileInputStream(zipFile), tempDir);
        return tempDir;
    } catch (IOException e) {
        // attempt cleanup, then re-throw
        org.apache.commons.io.FileUtils.deleteDirectory(tempDir);
        throw e;
    }
}

From source file:cn.isif.util_plus.util.OtherUtils.java

public static long getAvailableSpace(File dir) {
    try {//from   ww w.j a v  a 2 s  .  co  m
        final StatFs stats = new StatFs(dir.getPath());
        return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
    } catch (Throwable e) {
        LogUtils.e(e.getMessage(), e);
        return -1;
    }

}

From source file:com.ddiiyy.xydz.xutils.util.OtherUtils.java

@SuppressWarnings("deprecation")
public static long getAvailableSpace(File dir) {
    try {/*from   ww w  .j a va  2s .  c om*/
        final StatFs stats = new StatFs(dir.getPath());
        return (long) stats.getBlockSize() * (long) stats.getAvailableBlocks();
    } catch (Throwable e) {
        LogUtils.e(e.getMessage(), e);
        return -1;
    }

}