Tabnine Logo
File.getAbsolutePath
Code IndexAdd Tabnine to your IDE (free)

How to use
getAbsolutePath
method
in
java.io.File

Best Java code snippets using java.io.File.getAbsolutePath (Showing top 20 results out of 114,327)

Refine searchRefine arrow

  • File.<init>
  • File.exists
  • File.isDirectory
  • File.mkdirs
  • File.getName
  • PrintStream.println
origin: stackoverflow.com

 File imgFile = new  File("/sdcard/Images/test_image.jpg");

if(imgFile.exists()){

  Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());

  ImageView myImage = (ImageView) findViewById(R.id.imageviewTest);

  myImage.setImageBitmap(myBitmap);

}
origin: skylot/jadx

private InputFile(File file) throws IOException {
  if (!file.exists()) {
    throw new IOException("File not found: " + file.getAbsolutePath());
  }
  this.file = file;
}
origin: stackoverflow.com

System.out.println(new File(".").getAbsolutePath());
origin: apache/zookeeper

/**
 * @param filePath the file path to be validated
 * @return Returns null if valid otherwise error message
 */
public static String validateFileInput(String filePath) {
  File file = new File(filePath);
  if (!file.exists()) {
    return "File '" + file.getAbsolutePath() + "' does not exist.";
  }
  if (!file.canRead()) {
    return "Read permission is denied on the file '" + file.getAbsolutePath() + "'";
  }
  if (file.isDirectory()) {
    return "'" + file.getAbsolutePath() + "' is a direcory. it must be a file.";
  }
  return null;
}
origin: stackoverflow.com

 // Assume block needs to be inside a Try/Catch block.
String path = Environment.getExternalStorageDirectory().toString();
OutputStream fOut = null;
Integer counter = 0;
File file = new File(path, "FitnessGirl"+counter+".jpg"); // the File to save , append increasing numeric counter to prevent files from getting overwritten.
fOut = new FileOutputStream(file);

Bitmap pictureBitmap = getImageBitmap(myurl); // obtaining the Bitmap
pictureBitmap.compress(Bitmap.CompressFormat.JPEG, 85, fOut); // saving the Bitmap to a file compressed as a JPEG with 85% compression rate
fOut.flush(); // Not really required
fOut.close(); // do not forget to close the stream

MediaStore.Images.Media.insertImage(getContentResolver(),file.getAbsolutePath(),file.getName(),file.getName());
origin: Tencent/tinker

private static void setRunningLocation(CliMain m) {
  mRunningLocation = m.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
  try {
    mRunningLocation = URLDecoder.decode(mRunningLocation, "utf-8");
  } catch (UnsupportedEncodingException e) {
    e.printStackTrace();
  }
  if (mRunningLocation.endsWith(".jar")) {
    mRunningLocation = mRunningLocation.substring(0, mRunningLocation.lastIndexOf(File.separator) + 1);
  }
  File f = new File(mRunningLocation);
  mRunningLocation = f.getAbsolutePath();
}
origin: stackoverflow.com

 File sdCard = Environment.getExternalStorageDirectory();
File dir = new File (sdCard.getAbsolutePath() + "/dir1/dir2");
dir.mkdirs();
File file = new File(dir, "filename");

FileOutputStream f = new FileOutputStream(file);
...
origin: neo4j/neo4j

  @Override
  File ensureDirectoryExists( FileSystemAbstraction fileSystem, File dir )
  {
    if ( !dir.exists() && !dir.mkdirs() )
    {
      String message = String.format( "Unable to create directory path[%s] for Neo4j store" + ".",
          dir.getAbsolutePath() );
      throw new RuntimeException( message );
    }
    return dir;
  }
},
origin: skylot/jadx

private static void checkFile(File file) {
  if (!file.exists()) {
    throw new JadxArgsValidateException("File not found " + file.getAbsolutePath());
  }
  if (file.isDirectory()) {
    throw new JadxArgsValidateException("Expected file but found directory instead: " + file.getAbsolutePath());
  }
}
origin: redisson/redisson

/**
 * Compresses a file into gzip archive.
 */
public static File gzip(File file) throws IOException {
  if (file.isDirectory()) {
    throw new IOException("Can't gzip folder");
  }
  FileInputStream fis = new FileInputStream(file);
  String gzipName = file.getAbsolutePath() + GZIP_EXT;
  GZIPOutputStream gzos = new GZIPOutputStream(new FileOutputStream(gzipName));
  try {
    StreamUtil.copy(fis, gzos);
  } finally {
    StreamUtil.close(gzos);
    StreamUtil.close(fis);
  }
  return new File(gzipName);
}
origin: apache/flink

protected static void deleteRecursively(File f) throws IOException {
  if (f.isDirectory()) {
    FileUtils.deleteDirectory(f);
  } else if (!f.delete()) {
    System.err.println("Failed to delete file " + f.getAbsolutePath());
  }
}
origin: Tencent/tinker

private void unzipApkFile(File file, File destFile) throws TinkerPatchException, IOException {
  String apkName = file.getName();
  if (!apkName.endsWith(TypedValue.FILE_APK)) {
    throw new TinkerPatchException(
      String.format("input apk file path must end with .apk, yours %s\n", apkName)
    );
  }
  String destPath = destFile.getAbsolutePath();
  Logger.d("UnZipping apk to %s", destPath);
  FileOperation.unZipAPk(file.getAbsoluteFile().getAbsolutePath(), destPath);
}
origin: Tencent/tinker

/**
 * @param output unsigned apk file output
 * @throws IOException
 */
private void generateUnsignedApk(File output) throws IOException {
  Logger.d("Generate unsigned apk: %s", output.getName());
  final File tempOutDir = config.mTempResultDir;
  if (!tempOutDir.exists()) {
    throw new IOException(String.format(
      "Missing patch unzip files, path=%s\n", tempOutDir.getAbsolutePath()));
  }
  FileOperation.zipInputDir(tempOutDir, output, null);
  if (!output.exists()) {
    throw new IOException(String.format(
      "can not found the unsigned apk file path=%s",
      output.getAbsolutePath()));
  }
}
origin: hs-web/hsweb-framework

  public static FileInfo from(File file) {
    FileInfo info = new FileInfo();
    info.setName(file.getName());
    info.setLength(file.length());
    info.setParent(file.getParent());
    info.setAbsolutePath(file.getAbsolutePath());
    info.setFile(file.isFile());
    info.setDir(file.isDirectory());
    return info;
  }
}
origin: redisson/redisson

/**
 * Scans single path.
 */
protected void scanPath(File file) {
  String path = file.getAbsolutePath();
  if (StringUtil.endsWithIgnoreCase(path, JAR_FILE_EXT)) {
    if (!acceptJar(file)) {
      return;
    }
    scanJarFile(file);
  } else if (file.isDirectory()) {
    scanClassPath(file);
  }
}
origin: libgdx/libgdx

private void copyAndReplace (String outputDir, Project project, Map<String, String> values) {
  File out = new File(outputDir);
  if (!out.exists() && !out.mkdirs()) {
    throw new RuntimeException("Couldn't create output directory '" + out.getAbsolutePath() + "'");
  }
  for (ProjectFile file : project.files) {
    copyFile(file, out, values);
  }
}
origin: iBotPeaches/Apktool

public static String getAaptExecutionCommand(String aaptPath, File aapt) throws BrutException {
  if (! aaptPath.isEmpty()) {
    File aaptFile = new File(aaptPath);
    if (aaptFile.canRead() && aaptFile.exists()) {
      aaptFile.setExecutable(true);
      return aaptFile.getPath();
    } else {
      throw new BrutException("binary could not be read: " + aaptFile.getAbsolutePath());
    }
  } else {
    return aapt.getAbsolutePath();
  }
}
origin: stackoverflow.com

 File f = new File("C:\\Hello\\AnotherFolder\\The File Name.PDF");  
System.out.println(f.getAbsolutePath().substring(f.getAbsolutePath().lastIndexOf("\\")+1));
origin: gocd/gocd

public static boolean isSymbolicLink(File parent, String name)
    throws IOException {
  if (parent == null) {
    File f = new File(name);
    parent = f.getParentFile();
    name = f.getName();
  }
  File toTest = new File(parent.getCanonicalPath(), name);
  return !toTest.getAbsolutePath().equals(toTest.getCanonicalPath());
}
origin: androidannotations/androidannotations

private File resolveLogFileInSpecifiedPath(String logFile) throws FileNotFoundException {
  File outputDirectory = FileHelper.resolveOutputDirectory(processingEnv);
  logFile = logFile.replace("{outputFolder}", outputDirectory.getAbsolutePath());
  return new File(logFile);
}
java.ioFilegetAbsolutePath

Javadoc

Returns the absolute path of this file. An absolute path is a path that starts at a root of the file system. On Android, there is only one root: /.

A common use for absolute paths is when passing paths to a Process as command-line arguments, to remove the requirement implied by relative paths, that the child must have the same working directory as its parent.

Popular methods of File

  • <init>
    Creates a new File instance by converting the givenfile: URI into an abstract pathname. The exact fo
  • exists
    Tests whether the file or directory denoted by this abstract pathname exists.
  • getName
    Returns the name of the file or directory denoted by this abstract pathname. This is just the last n
  • isDirectory
  • mkdirs
  • delete
    Deletes the file or directory denoted by this abstract pathname. If this pathname denotes a director
  • listFiles
    Returns an array of abstract pathnames denoting the files and directories in the directory denoted b
  • getParentFile
    Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not
  • getPath
    Converts this abstract pathname into a pathname string. The resulting string uses the #separator to
  • isFile
  • length
    Returns the length of the file denoted by this abstract pathname. The return value is unspecified if
  • toURI
  • length,
  • toURI,
  • createTempFile,
  • createNewFile,
  • toPath,
  • mkdir,
  • lastModified,
  • toString,
  • getCanonicalPath

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (Timer)
  • runOnUiThread (Activity)
  • getSharedPreferences (Context)
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • BoxLayout (javax.swing)
  • JButton (javax.swing)
  • JCheckBox (javax.swing)
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now