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:com.plugin.excel.xsd.node.store.impl.FileHelper.java

public static List<String> getAllXsds(String directoryLocation) {

    if (StringUtils.isNotBlank(directoryLocation)) {
        List<File> files = new ArrayList<File>();
        findFiles(directoryLocation, files);
        if (!files.isEmpty()) {
            List<String> fileStrs = new ArrayList<String>();
            for (File file : files) {
                fileStrs.add(file.getPath());
            }// w w  w. ja  v a  2 s  . co  m
            return fileStrs;
        }
    }

    return null;
}

From source file:com.sunchenbin.store.feilong.core.io.SpecialFolder.java

/**
 * ?<br>//from ww  w. j  a v a 2  s . c om
 * example:win7:C:\Users\venusdrogon\Desktop.
 * 
 * <br>
 *  ?? USERPROFILE<br>
 * return C:\Users\venusdrogon ? Desktop 
 * 
 * @return ??
 * @see FileSystemView#getHomeDirectory()
 */
public static String getDesktop() {
    FileSystemView fileSystemView = FileSystemView.getFileSystemView();
    File file = fileSystemView.getHomeDirectory();
    //  ?? USERPROFILE======>C:\Users\venusdrogon ? Desktop 
    return file.getPath();
}

From source file:frankhassanabad.com.github.Jasperize.java

/**
 * Compiles all the jrxml template files into an output directory.  This does just a one directory
 * deep scan for files.//from   w ww. ja  va 2 s  .  com
 * @param inputDirectory The input directory containing all the jrxml's.
 * @param outputDirectory The output directory to put all the .jasper files.
 * @throws JRException If there's any problems compiling a jrxml, this will get thrown.
 */
private static void compileAllJrxmlTemplateFiles(String inputDirectory, String outputDirectory)
        throws JRException {
    //compile all .jrxml's from the JasperTemplates directory into the jasperOutput directory.
    File jrxmlInputFolder = new File(inputDirectory);
    File[] jrxmlFiles = jrxmlInputFolder.listFiles(new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            return pathname.getName().endsWith("jrxml");
        }
    });
    for (File jrxmlFileFile : jrxmlFiles) {
        String inputFile = jrxmlFileFile.getPath();
        String nameWithNoExtension = jrxmlFileFile.getName().split("\\.")[0];
        String outputFile = outputDirectory + File.separator + nameWithNoExtension + ".jasper";
        System.out.println("Compiling: " + jrxmlFileFile);
        Reporting.compile(inputFile, outputFile);
    }
}

From source file:Main.java

public static String getDirPath() {
    File mediaStorageDir = new File(
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Dove");
    if (!mediaStorageDir.exists())
        return null;
    else//from  w ww .j  av a2  s . c om
        return mediaStorageDir.getPath();

}

From source file:Main.java

public static void makedirs(File file) throws IOException {
    checkFile(file);//ww  w. ja  va2  s  .co  m
    File parentFile = file.getParentFile();
    if (parentFile != null) {
        if (!parentFile.exists() && !parentFile.mkdirs()) {
            throw new IOException("Creating directories " + parentFile.getPath() + " failed.");
        }
    }
}

From source file:com.feilong.commons.core.io.SpecialFolder.java

/**
 * ?<br>//from w  w w  .j  ava 2  s . co m
 * example:win7:C:\Users\venusdrogon\Desktop.
 * 
 * <br>
 *  ?? USERPROFILE<br>
 * return C:\Users\venusdrogon ? Desktop 
 * 
 * @return ??
 * @see FileSystemView#getHomeDirectory()
 */
public static final String getDesktop() {
    FileSystemView fileSystemView = FileSystemView.getFileSystemView();
    File file = fileSystemView.getHomeDirectory();
    //  ?? USERPROFILE======>C:\Users\venusdrogon ? Desktop 
    return file.getPath();
}

From source file:com.github.fi3te.iliasdownloader.controller.Util.java

public static void openFile(File file, Activity forMessages) {
    if (file != null && forMessages != null && file.isFile()) {
        String extension = FilenameUtils.getExtension(file.getPath());
        if (extension.length() > 0) {
            try {
                extension = extension.toLowerCase();
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setDataAndType(Uri.fromFile(file),
                        MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension));
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                forMessages.startActivity(intent);
            } catch (ActivityNotFoundException anfe) {
                Toast.makeText(forMessages, forMessages.getResources().getString(R.string.unknown_type),
                        Toast.LENGTH_SHORT).show();
            }/*  w w  w . j  a  v  a 2s .  c o  m*/
        }
    }
}

From source file:Main.java

private static void searchDir(File dirFile) {
    File[] files = dirFile.listFiles();
    if (files != null) {
        for (File file : files) {
            if (file.isDirectory()) {
                if (file.getName().subSequence(0, 1).equals(".") || file.getName().equals("Android")
                        || file.getPath().equalsIgnoreCase("/storage/emulated")) {

                } else {
                    searchDir(file);//  w  w  w  .  j a  v  a  2s .  c o m
                }
            } else {
                if (file.getName().toLowerCase().contains(fileType.toLowerCase())) {
                    listFile.add(file);
                }
            }
        }
    }
}

From source file:com.vmware.content.samples.client.util.HttpUtil.java

/**
 * Downloads a file from a given HTTP URI in a given folder.
 *
 * @param uri HTTP URI to download file from.
 * @param folderToDownloadFiles path to a directory on the local storage
 *                              to store the download the files.
 * @param fileName name to use when creating the downloaded file on the local storage.
 * @throws java.security.NoSuchAlgorithmException
 * @throws java.security.KeyStoreException
 * @throws java.security.KeyManagementException
 * @throws java.io.IOException/*from  w w  w.  j  a  v  a  2  s  . c  o  m*/
 */
public static void downloadFileFromUri(URI uri, String folderToDownloadFiles, String fileName)
        throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException {
    HttpGet getRequest = new HttpGet(uri);
    CloseableHttpClient httpClient = getCloseableHttpClient();
    HttpResponse response = httpClient.execute(getRequest);
    File file = new File(folderToDownloadFiles, fileName);
    response.getEntity().writeTo(new FileOutputStream(file));
    IOUtil.print("Downloaded: " + file.getPath());
}

From source file:apim.restful.exportimport.utils.ArchiveGenerator.java

public static void writeZipFile(File directoryToZip, List<File> fileList) {

    try {/*from   w  ww .j  a  v  a 2  s.  c  o  m*/
        FileOutputStream fos = new FileOutputStream(directoryToZip.getPath() + ".zip");
        ZipOutputStream zos = new ZipOutputStream(fos);

        for (File file : fileList) {
            if (!file.isDirectory()) { // we only zip files, not directories
                addToZip(directoryToZip, file, zos);
            }
        }

        zos.close();
        fos.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}