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

How to use
isAbsolute
method
in
java.io.File

Best Java code snippets using java.io.File.isAbsolute (Showing top 20 results out of 11,241)

Refine searchRefine arrow

  • File.<init>
  • File.exists
  • File.getAbsolutePath
  • File.getPath
  • File.isDirectory
  • File.getParentFile
origin: libgdx/libgdx

public File getAbsoluteFile () {
  if (isAbsolute()) {
    return this;
  }
  if (parent == null) {
    return new File(ROOT, name);
  }
  return new File(parent.getAbsoluteFile(), name);
}
origin: jenkinsci/jenkins

private static File resolve(File base, String relative) {
  File rel = new File(relative);
  if(rel.isAbsolute())
    return rel;
  else
    return new File(base.getParentFile(),relative);
}
origin: thinkaurelius/titan

private static final String getAbsolutePath(final File configParent, String file) {
  File storedir = new File(file);
  if (!storedir.isAbsolute()) {
    String newFile = configParent.getAbsolutePath() + File.separator + file;
    log.debug("Overwrote relative path: was {}, now {}", file, newFile);
    return newFile;
  } else {
    log.debug("Loaded absolute path for key: {}", file);
    return file;
  }
}
origin: spotbugs/spotbugs

private String makeAbsolute(String possiblyRelativePath) {
  if (possiblyRelativePath.contains("://") || possiblyRelativePath.startsWith("http:")
      || possiblyRelativePath.startsWith("https:") || possiblyRelativePath.startsWith("file:")) {
    return possiblyRelativePath;
  }
  if (base == null) {
    return possiblyRelativePath;
  }
  if (new File(possiblyRelativePath).isAbsolute()) {
    return possiblyRelativePath;
  }
  return new File(base.getParentFile(), possiblyRelativePath).getAbsolutePath();
}
origin: org.apache.ant/ant

private boolean isExistingAbsoluteFile(String name) {
  File f = new File(name);
  return f.isAbsolute() && f.exists();
}
origin: gocd/gocd

public static File applyBaseDirIfRelative(File baseDir, File actualFileToUse) {
  if (actualFileToUse == null) {
    return baseDir;
  }
  if (actualFileToUse.isAbsolute()) {
    return actualFileToUse;
  }
  if (StringUtils.isBlank(baseDir.getPath())) {
    return actualFileToUse;
  }
  return new File(baseDir, actualFileToUse.getPath());
}
origin: apache/maven

@Override
public String alignToBaseDirectory( String path, File basedir )
{
  String result = path;
  if ( path != null && basedir != null )
  {
    path = path.replace( '\\', File.separatorChar ).replace( '/', File.separatorChar );
    File file = new File( path );
    if ( file.isAbsolute() )
    {
      // path was already absolute, just normalize file separator and we're done
      result = file.getPath();
    }
    else if ( file.getPath().startsWith( File.separator ) )
    {
      // drive-relative Windows path, don't align with project directory but with drive root
      result = file.getAbsolutePath();
    }
    else
    {
      // an ordinary relative path, align with project directory
      result = new File( new File( basedir, path ).toURI().normalize() ).getAbsolutePath();
    }
  }
  return result;
}
origin: apache/activemq

private void forceRemoveDataFile(DataFile dataFile) throws IOException {
  accessorPool.disposeDataFileAccessors(dataFile);
  totalLength.addAndGet(-dataFile.getLength());
  if (archiveDataLogs) {
    File directoryArchive = getDirectoryArchive();
    if (directoryArchive.exists()) {
      LOG.debug("Archive directory exists: {}", directoryArchive);
    } else {
      if (directoryArchive.isAbsolute())
      if (LOG.isDebugEnabled()) {
        LOG.debug("Archive directory [{}] does not exist - creating it now",
            directoryArchive.getAbsolutePath());
      }
      IOHelper.mkdirs(directoryArchive);
    }
    LOG.debug("Moving data file {} to {} ", dataFile, directoryArchive.getCanonicalPath());
    dataFile.move(directoryArchive);
    LOG.debug("Successfully moved data file");
  } else {
    LOG.debug("Deleting data file: {}", dataFile);
    if (dataFile.delete()) {
      LOG.debug("Discarded data file: {}", dataFile);
    } else {
      LOG.warn("Failed to discard data file : {}", dataFile.getFile());
    }
  }
  if (dataFileRemovedListener != null) {
    dataFileRemovedListener.fileRemoved(dataFile);
  }
}
origin: thinkaurelius/titan

private static String loadAbsoluteDirectoryPath(String name, String prop, boolean mustExistAndBeAbsolute) {
  String s = System.getProperty(prop);
  if (null == s) {
    s = Joiner.on(File.separator).join(System.getProperty("user.dir"), "target", "cassandra", name, "localhost-bop");
    log.info("Set default Cassandra {} directory path {}", name, s);
  } else {
    log.info("Loaded Cassandra {} directory path {} from system property {}", new Object[] { name, s, prop });
  }
  if (mustExistAndBeAbsolute) {
    File dir = new File(s);
    Preconditions.checkArgument(dir.isDirectory(), "Path %s must be a directory", s);
    Preconditions.checkArgument(dir.isAbsolute(),  "Path %s must be absolute", s);
  }
  return s;
}
origin: spring-projects/spring-framework

@Override
public void transferTo(File dest) throws IOException, IllegalStateException {
  this.part.write(dest.getPath());
  if (dest.isAbsolute() && !dest.exists()) {
    // Servlet 3.0 Part.write is not guaranteed to support absolute file paths:
    // may translate the given path to a relative location within a temp dir
    // (e.g. on Jetty whereas Tomcat and Undertow detect absolute paths).
    // At least we offloaded the file from memory storage; it'll get deleted
    // from the temp dir eventually in any case. And for our user's purposes,
    // we can manually copy it to the requested location as a fallback.
    FileCopyUtils.copy(this.part.getInputStream(), Files.newOutputStream(dest.toPath()));
  }
}
origin: SonarSource/sonarqube

@Override
public FilePredicate is(File ioFile) {
 if (ioFile.isAbsolute()) {
  return hasAbsolutePath(ioFile.getAbsolutePath());
 }
 return hasRelativePath(ioFile.getPath());
}
origin: apache/zookeeper

private void doWarnForRelativePath(File file) {
  if(file.isAbsolute()) return;
  if(file.getPath().substring(0, 2).equals("."+File.separator)) return;
  log.warn(file.getPath()+" is relative. Prepend ."
      +File.separator+" to indicate that you're sure!");
}
origin: crashub/crash

public static Path get(java.io.File file) {
 String[] names = path(file, 0);
 if (file.isAbsolute()) {
  return new Absolute(file.isDirectory(), names);
 } else {
  return new Relative(file.isDirectory(), names);
 }
}
origin: apache/activemq

  /**
   * Utility method to help find the root directory of the store
   *
   * @param dir
   * @return
   */
  public static File findParentDirectory(File dir) {
    if (dir != null) {
      String dirPath = dir.getAbsolutePath();
      if (!dir.isAbsolute()) {
        dir = new File(dirPath);
      }

      while (dir != null && !dir.isDirectory()) {
        dir = dir.getParentFile();
      }
    }
    return dir;
  }
}
origin: eclipse-vertx/vert.x

static List<File> extractRoots(File root, List<String> includes) {
 return includes.stream().map(s -> {
  if (s.startsWith("*")) {
   return root.getAbsolutePath();
  }
  if (s.contains("*")) {
   s = s.substring(0, s.indexOf("*"));
  }
  File file = new File(s);
  if (file.isAbsolute()) {
   return file.getAbsolutePath();
  } else {
   return new File(root, s).getAbsolutePath();
  }
 }).collect(Collectors.toSet()).stream().map(File::new).collect(Collectors.toList());
}
origin: bytedeco/javacpp

public void addAll(String key, Collection<String> values) {
  if (values != null) {
    String root = null;
    if (key.equals("platform.compiler") || key.equals("platform.sysroot") || key.equals("platform.toolchain") ||
        key.equals("platform.includepath") || key.equals("platform.linkpath")) {
      root = platformRoot;
    }
    List<String> values2 = get(key);
    for (String value : values) {
      if (value == null) {
        continue;
      }
      if (root != null && !new File(value).isAbsolute() &&
          new File(root + value).exists()) {
        value = root + value;
      }
      if (!values2.contains(value)) {
        values2.add(value);
      }
    }
  }
}
origin: SonarSource/sonarqube

@CheckForNull
private static File initModuleBuildDir(File moduleBaseDir, Map<String, String> moduleProperties) {
 String buildDir = moduleProperties.get(PROPERTY_PROJECT_BUILDDIR);
 if (StringUtils.isBlank(buildDir)) {
  return null;
 }
 File customBuildDir = new File(buildDir);
 if (customBuildDir.isAbsolute()) {
  return customBuildDir;
 }
 return new File(moduleBaseDir, customBuildDir.getPath());
}
origin: libgdx/libgdx

public File getAbsoluteFile () {
  if (isAbsolute()) {
    return this;
  }
  if (parent == null) {
    return new File(ROOT, name);
  }
  return new File(parent.getAbsoluteFile(), name);
}
origin: fabric8io/docker-maven-plugin

private String extractDockerFilePath(DockerComposeServiceWrapper mapper, File parentDir) {
  if (mapper.requiresBuild()) {
    File buildDir = new File(mapper.getBuildDir());
    String dockerFile = mapper.getDockerfile();
    if (dockerFile == null) {
      dockerFile = "Dockerfile";
    }
    File ret = new File(buildDir, dockerFile);
    return ret.isAbsolute() ? ret.getAbsolutePath() : new File(parentDir, ret.getPath()).getAbsolutePath();
  } else {
    return null;
  }
}
origin: geotools/geotools

/**
 * Creates a human readable message that describe the provided {@link File} object in terms of
 * its properties.
 *
 * <p>Useful for creating meaningful log messages.
 *
 * @param file the {@link File} object to create a descriptive message for
 * @return a {@link String} containing a descriptive message about the provided {@link File}.
 */
public static String getFileInfo(final File file) {
  final StringBuilder builder = new StringBuilder();
  builder.append("Checking file:")
      .append(FilenameUtils.getFullPath(file.getAbsolutePath()))
      .append("\n");
  builder.append("isHidden:").append(file.isHidden()).append("\n");
  builder.append("exists:").append(file.exists()).append("\n");
  builder.append("isFile").append(file.isFile()).append("\n");
  builder.append("canRead:").append(file.canRead()).append("\n");
  builder.append("canWrite").append(file.canWrite()).append("\n");
  builder.append("canExecute:").append(file.canExecute()).append("\n");
  builder.append("isAbsolute:").append(file.isAbsolute()).append("\n");
  builder.append("lastModified:").append(file.lastModified()).append("\n");
  builder.append("length:").append(file.length());
  final String message = builder.toString();
  return message;
}
java.ioFileisAbsolute

Javadoc

Indicates if this file's pathname is absolute. Whether a pathname is absolute is platform specific. On Android, absolute paths start with the character '/'.

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.
  • getAbsolutePath
    Returns the absolute pathname string of this abstract pathname. If this abstract pathname is already
  • 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
  • isFile,
  • length,
  • toURI,
  • createTempFile,
  • createNewFile,
  • toPath,
  • mkdir,
  • lastModified,
  • toString,
  • getCanonicalPath

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setScale (BigDecimal)
  • notifyDataSetChanged (ArrayAdapter)
  • scheduleAtFixedRate (Timer)
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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