Java Code Examples for org.apache.hadoop.fs.Path#isWindowsAbsolutePath()

The following examples show how to use org.apache.hadoop.fs.Path#isWindowsAbsolutePath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PathData.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private static String uriToString(URI uri, boolean inferredSchemeFromPath) {
  String scheme = uri.getScheme();
  // No interpretation of symbols. Just decode % escaped chars.
  String decodedRemainder = uri.getSchemeSpecificPart();

  // Drop the scheme if it was inferred to ensure fidelity between
  // the input and output path strings.
  if ((scheme == null) || (inferredSchemeFromPath)) {
    if (Path.isWindowsAbsolutePath(decodedRemainder, true)) {
      // Strip the leading '/' added in stringToUri so users see a valid
      // Windows path.
      decodedRemainder = decodedRemainder.substring(1);
    }
    return decodedRemainder;
  } else {
    StringBuilder buffer = new StringBuilder();
    buffer.append(scheme);
    buffer.append(":");
    buffer.append(decodedRemainder);
    return buffer.toString();
  }
}
 
Example 2
Source File: PathData.java    From big-c with Apache License 2.0 6 votes vote down vote up
private static String uriToString(URI uri, boolean inferredSchemeFromPath) {
  String scheme = uri.getScheme();
  // No interpretation of symbols. Just decode % escaped chars.
  String decodedRemainder = uri.getSchemeSpecificPart();

  // Drop the scheme if it was inferred to ensure fidelity between
  // the input and output path strings.
  if ((scheme == null) || (inferredSchemeFromPath)) {
    if (Path.isWindowsAbsolutePath(decodedRemainder, true)) {
      // Strip the leading '/' added in stringToUri so users see a valid
      // Windows path.
      decodedRemainder = decodedRemainder.substring(1);
    }
    return decodedRemainder;
  } else {
    StringBuilder buffer = new StringBuilder();
    buffer.append(scheme);
    buffer.append(":");
    buffer.append(decodedRemainder);
    return buffer.toString();
  }
}