Example usage for java.io File getAbsolutePath

List of usage examples for java.io File getAbsolutePath

Introduction

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

Prototype

public String getAbsolutePath() 

Source Link

Document

Returns the absolute pathname string of this abstract pathname.

Usage

From source file:com.synopsys.integration.executable.Executable.java

public static Executable create(final File workingDirectory, File executableFile) {
    return create(workingDirectory, executableFile.getAbsolutePath(), Collections.emptyList());
}

From source file:Main.java

public static void openFile(File aFile, Context context) {
    Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW);
    File file = new File(aFile.getAbsolutePath());
    String extension = android.webkit.MimeTypeMap.getFileExtensionFromUrl(Uri.fromFile(file).toString());
    String mimetype = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
    myIntent.setDataAndType(Uri.fromFile(file), mimetype);

    context.startActivity(myIntent);/*from   www  .  j  ava2 s  . c o  m*/
}

From source file:Main.java

public static void saveBitmap2file(Bitmap bmp, File file) {

    OutputStream stream = null;//from w w w.j  a  v a2  s. com
    try {
        stream = new FileOutputStream(file.getAbsolutePath());
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    bmp.compress(Bitmap.CompressFormat.JPEG, 100, stream);

    try {
        stream.flush();
    } catch (IOException e) {
        e.printStackTrace();
    }

    try {
        stream.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:com.adguard.compiler.PackageUtils.java

public static File createXpi(String makeXpiSh, File file, String xpiName) throws Exception {
    execute(makeXpiSh, file.getAbsolutePath());
    File xpiFile = new File(file, xpiName + ".xpi");
    File destXpiFile = new File(file.getParentFile(), file.getName() + ".xpi");
    if (destXpiFile.exists()) {
        FileUtils.deleteQuietly(destXpiFile);
    }//  ww  w. j  a v  a 2s .c  o m
    FileUtils.moveFile(xpiFile, destXpiFile);
    FileUtils.deleteQuietly(file);
    return destXpiFile;
}

From source file:com.opendoorlogistics.core.utils.io.TextIO.java

private static String getTableName(File file) {
    String tableName = FilenameUtils.getBaseName(file.getAbsolutePath());
    if (Strings.isEmptyWhenStandardised(tableName)) {
        tableName = "Table";
    }/*from www.j  a  v a 2  s .com*/
    return tableName;
}

From source file:com.cloud.servlet.StaticResourceServlet.java

static File getCompressedVersion(final File requestedFile) {
    return new File(requestedFile.getAbsolutePath() + ".gz");
}

From source file:Main.java

/**
 * Browse to a folder./*from   w w  w. j a v  a2  s.c o  m*/
 * 
 * @param file the path
 * @param component the component
 */
public static void browseDir(File file, Component component) {
    try {
        Desktop.getDesktop().browse(new URL("file://" + file.getAbsolutePath()).toURI());
    } catch (IOException e) {
        JOptionPane.showMessageDialog(component,
                "Unable to open '" + file.getAbsolutePath() + "'. Maybe it doesn't exist?", "Open failed",
                JOptionPane.ERROR_MESSAGE);
    } catch (URISyntaxException e) {
    }
}

From source file:Main.java

public static boolean compressAndSaveBitmap(File input, File output, int width, int height, int quality) {
    Bitmap bitmap = getSmallBitmap(input.getAbsolutePath(), width, height);
    return saveBitmap(bitmap, output.getAbsolutePath(), quality);
}

From source file:Main.java

private static void mergeExeBatchFiles() {
    File file = new File(batchDir);
    System.out.println("debug:current path = " + file.getAbsolutePath());
    File[] files = file.listFiles();
    if (files == null || files.length == 0) {
        return;//from w  w  w .  j a v a  2  s.  co  m
    }
    Arrays.sort(files, new Comparator<File>() {
        public int compare(File file1, File file2) {
            if (file1.lastModified() > file2.lastModified()) {
                return 1;
            } else if (file1.lastModified() < file2.lastModified()) {
                return -1;
            } else {
                return 0;
            }
        }
    });
    StringBuffer command = new StringBuffer();
    for (File f : files) {
        command.append("call ").append(f.getAbsolutePath()).append("\n");
    }
    try {
        String filePath = batchDir + "build.bat";
        writeFile(filePath, command.toString());
        Runtime.getRuntime().exec("cmd /c start " + filePath);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

/**
 * Get the left size of the SDCard in Bytes.
 * /*w w  w. j a v a 2  s.c o m*/
 * @return the left size
 */
@SuppressWarnings("deprecation")
public static long getSDCardLeftSize() {
    File sdcard = Environment.getExternalStorageDirectory();
    if (sdcard.exists()) {
        StatFs statFs = new StatFs(sdcard.getAbsolutePath());
        long blockSize = statFs.getBlockSize();
        long availableBlocks = statFs.getAvailableBlocks();

        return blockSize * availableBlocks;
    }

    return 0;
}