java.io.File.getAbsoluteName()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(202)

本文整理了Java中java.io.File.getAbsoluteName()方法的一些代码示例,展示了File.getAbsoluteName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。File.getAbsoluteName()方法的具体详情如下:
包路径:java.io.File
类名称:File
方法名:getAbsoluteName

File.getAbsoluteName介绍

暂无

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Returns a Uniform Resource Identifier for this file. The URI is system
 * dependent and may not be transferable between different operating / file
 * systems.
 *
 * @return an URI for this file.
 */
public URI toURI() {
  String name = getAbsoluteName();
  try {
    if (!name.startsWith("/")) {
      // start with sep.
      return new URI("file", null, "/" + name, null, null);
    } else if (name.startsWith("//")) {
      return new URI("file", "", name, null); // UNC path
    }
    return new URI("file", null, name, null, null);
  } catch (URISyntaxException e) {
    // this should never happen
    return null;
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Returns a Uniform Resource Locator for this file. The URL is system
 * dependent and may not be transferable between different operating / file
 * systems.
 *
 * @return a URL for this file.
 * @throws java.net.MalformedURLException
 *             if the path cannot be transformed into a URL.
 * @deprecated Use {@link #toURI} and {@link java.net.URI#toURL} to
 * correctly escape illegal characters.
 */
@Deprecated
public URL toURL() throws java.net.MalformedURLException {
  String name = getAbsoluteName();
  if (!name.startsWith("/")) {
    // start with sep.
    return new URL("file", "", -1, "/" + name, null);
  } else if (name.startsWith("//")) {
    return new URL("file:" + name); // UNC path
  }
  return new URL("file", "", -1, name, null);
}

代码示例来源:origin: MobiVM/robovm

/**
 * Returns a Uniform Resource Identifier for this file. The URI is system
 * dependent and may not be transferable between different operating / file
 * systems.
 *
 * @return an URI for this file.
 */
public URI toURI() {
  String name = getAbsoluteName();
  try {
    if (!name.startsWith("/")) {
      // start with sep.
      return new URI("file", null, "/" + name, null, null);
    } else if (name.startsWith("//")) {
      return new URI("file", "", name, null); // UNC path
    }
    return new URI("file", null, name, null, null);
  } catch (URISyntaxException e) {
    // this should never happen
    return null;
  }
}

代码示例来源:origin: ibinti/bugvm

/**
 * Returns a Uniform Resource Locator for this file. The URL is system
 * dependent and may not be transferable between different operating / file
 * systems.
 *
 * @return a URL for this file.
 * @throws java.net.MalformedURLException
 *             if the path cannot be transformed into a URL.
 * @deprecated Use {@link #toURI} and {@link java.net.URI#toURL} to
 * correctly escape illegal characters.
 */
@Deprecated
public URL toURL() throws java.net.MalformedURLException {
  String name = getAbsoluteName();
  if (!name.startsWith("/")) {
    // start with sep.
    return new URL("file", "", -1, "/" + name, null);
  } else if (name.startsWith("//")) {
    return new URL("file:" + name); // UNC path
  }
  return new URL("file", "", -1, name, null);
}

代码示例来源:origin: ibinti/bugvm

/**
 * Returns a Uniform Resource Identifier for this file. The URI is system
 * dependent and may not be transferable between different operating / file
 * systems.
 *
 * @return an URI for this file.
 */
public URI toURI() {
  String name = getAbsoluteName();
  try {
    if (!name.startsWith("/")) {
      // start with sep.
      return new URI("file", null, "/" + name, null, null);
    } else if (name.startsWith("//")) {
      return new URI("file", "", name, null); // UNC path
    }
    return new URI("file", null, name, null, null);
  } catch (URISyntaxException e) {
    // this should never happen
    return null;
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Returns a Uniform Resource Identifier for this file. The URI is system
 * dependent and may not be transferable between different operating / file
 * systems.
 *
 * @return an URI for this file.
 */
public URI toURI() {
  String name = getAbsoluteName();
  try {
    if (!name.startsWith("/")) {
      // start with sep.
      return new URI("file", null, "/" + name, null, null);
    } else if (name.startsWith("//")) {
      return new URI("file", "", name, null); // UNC path
    }
    return new URI("file", null, name, null, null);
  } catch (URISyntaxException e) {
    // this should never happen
    return null;
  }
}

代码示例来源:origin: MobiVM/robovm

/**
 * Returns a Uniform Resource Locator for this file. The URL is system
 * dependent and may not be transferable between different operating / file
 * systems.
 *
 * @return a URL for this file.
 * @throws java.net.MalformedURLException
 *             if the path cannot be transformed into a URL.
 * @deprecated Use {@link #toURI} and {@link java.net.URI#toURL} to
 * correctly escape illegal characters.
 */
@Deprecated
public URL toURL() throws java.net.MalformedURLException {
  String name = getAbsoluteName();
  if (!name.startsWith("/")) {
    // start with sep.
    return new URL("file", "", -1, "/" + name, null);
  } else if (name.startsWith("//")) {
    return new URL("file:" + name); // UNC path
  }
  return new URL("file", "", -1, name, null);
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns a Uniform Resource Identifier for this file. The URI is system
 * dependent and may not be transferable between different operating / file
 * systems.
 *
 * @return an URI for this file.
 */
public URI toURI() {
  String name = getAbsoluteName();
  try {
    if (!name.startsWith("/")) {
      // start with sep.
      return new URI("file", null, "/" + name, null, null);
    } else if (name.startsWith("//")) {
      return new URI("file", "", name, null); // UNC path
    }
    return new URI("file", null, name, null, null);
  } catch (URISyntaxException e) {
    // this should never happen
    return null;
  }
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Returns a Uniform Resource Identifier for this file. The URI is system
 * dependent and may not be transferable between different operating / file
 * systems.
 *
 * @return an URI for this file.
 */
public URI toURI() {
  String name = getAbsoluteName();
  try {
    if (!name.startsWith("/")) {
      // start with sep.
      return new URI("file", null, "/" + name, null, null);
    } else if (name.startsWith("//")) {
      return new URI("file", "", name, null); // UNC path
    }
    return new URI("file", null, name, null, null);
  } catch (URISyntaxException e) {
    // this should never happen
    return null;
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Returns a Uniform Resource Locator for this file. The URL is system
 * dependent and may not be transferable between different operating / file
 * systems.
 *
 * @return a URL for this file.
 * @throws java.net.MalformedURLException
 *             if the path cannot be transformed into a URL.
 * @deprecated Use {@link #toURI} and {@link java.net.URI#toURL} to
 * correctly escape illegal characters.
 */
@Deprecated
public URL toURL() throws java.net.MalformedURLException {
  String name = getAbsoluteName();
  if (!name.startsWith("/")) {
    // start with sep.
    return new URL("file", "", -1, "/" + name, null);
  } else if (name.startsWith("//")) {
    return new URL("file:" + name); // UNC path
  }
  return new URL("file", "", -1, name, null);
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns a Uniform Resource Locator for this file. The URL is system
 * dependent and may not be transferable between different operating / file
 * systems.
 *
 * @return a URL for this file.
 * @throws java.net.MalformedURLException
 *             if the path cannot be transformed into a URL.
 * @deprecated Use {@link #toURI} and {@link java.net.URI#toURL} to
 * correctly escape illegal characters.
 */
@Deprecated
public URL toURL() throws java.net.MalformedURLException {
  String name = getAbsoluteName();
  if (!name.startsWith("/")) {
    // start with sep.
    return new URL("file", "", -1, "/" + name, null);
  } else if (name.startsWith("//")) {
    return new URL("file:" + name); // UNC path
  }
  return new URL("file", "", -1, name, null);
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * Returns a Uniform Resource Locator for this file. The URL is system
 * dependent and may not be transferable between different operating / file
 * systems.
 *
 * @return a URL for this file.
 * @throws java.net.MalformedURLException
 *             if the path cannot be transformed into a URL.
 * @deprecated Use {@link #toURI} and {@link java.net.URI#toURL} to
 * correctly escape illegal characters.
 */
@Deprecated
public URL toURL() throws java.net.MalformedURLException {
  String name = getAbsoluteName();
  if (!name.startsWith("/")) {
    // start with sep.
    return new URL("file", "", -1, "/" + name, null);
  } else if (name.startsWith("//")) {
    return new URL("file:" + name); // UNC path
  }
  return new URL("file", "", -1, name, null);
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Returns a Uniform Resource Locator for this file. The URL is system
 * dependent and may not be transferable between different operating / file
 * systems.
 *
 * @return a URL for this file.
 * @throws java.net.MalformedURLException
 *             if the path cannot be transformed into a URL.
 * @deprecated Use {@link #toURI} and {@link java.net.URI#toURL} to
 * correctly escape illegal characters.
 */
@Deprecated
public URL toURL() throws java.net.MalformedURLException {
  String name = getAbsoluteName();
  if (!name.startsWith("/")) {
    // start with sep.
    return new URL("file", "", -1, "/" + name, null);
  } else if (name.startsWith("//")) {
    return new URL("file:" + name); // UNC path
  }
  return new URL("file", "", -1, name, null);
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * Returns a Uniform Resource Identifier for this file. The URI is system
 * dependent and may not be transferable between different operating / file
 * systems.
 *
 * @return an URI for this file.
 */
public URI toURI() {
  String name = getAbsoluteName();
  try {
    if (!name.startsWith("/")) {
      // start with sep.
      return new URI("file", null, "/" + name, null, null);
    } else if (name.startsWith("//")) {
      return new URI("file", "", name, null); // UNC path
    }
    return new URI("file", null, name, null, null);
  } catch (URISyntaxException e) {
    // this should never happen
    return null;
  }
}

相关文章