Java 8 InvalidPathException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 InvalidPathException class.

This code example shows how to use the following methods:
        // TODO merged from 9.2, check if necessary 
        String str = path.toString();
        int idx = StringUtil.indexOfControlChars(str);
        if(idx >= 0)
        { 
            throw new InvalidPathException(str, "Invalid Character at index " + idx);
        } 
    } 
     
    @Override 
    public void close() 
    { 
        // not applicable for FileSytem / Path 
    } 
 
    @Override 
    public boolean delete() throws SecurityException
    { 
        try 
        { 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    private void assertValidPath(String path)
    { 
        int idx = StringUtil.indexOfControlChars(path);
        if (idx >= 0)
        { 
            throw new InvalidPathException(path, "Invalid Character at index " + idx);
        } 
    } 
 
    /* ------------------------------------------------------------ */ 
    @Override 
    public URI getAlias()
    { 
        return _alias;
    } 
     
    /* -------------------------------------------------------- */ 
    /** 
     * Returns true if the resource exists. 
     */ 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getInput, getReason
 
    try { 
      windows.parsePath("\\\\");
      fail(); 
    } catch (InvalidPathException expected) {
      assertThat(expected.getInput()).isEqualTo("\\\\");
      assertThat(expected.getReason()).isEqualTo("UNC path is missing hostname");
    } 
 
    try { 
      windows.parsePath("\\\\host");
      fail(); 
    } catch (InvalidPathException expected) {
      assertThat(expected.getInput()).isEqualTo("\\\\host");
      assertThat(expected.getReason()).isEqualTo("UNC path is missing sharename");
    } 
 
    try { 
      windows.parsePath("\\\\host\\");
      fail(); 

4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
      } 
 
      return path.substring(uncMatcher.start(), uncMatcher.end());
    } else { 
      // probably shouldn't ever reach this 
      throw new InvalidPathException(original, "Invalid UNC path");
    } 
  } 
 
  /** 
   * Pattern for matching normal C:\ drive letter root syntax. 
   */ 
  private static final Pattern DRIVE_LETTER_ROOT = Pattern.compile("^[a-zA-Z]:\\\\");
 
  /** 
   * Parses a normal drive-letter root, e.g. "C:\". 
   */ 
  @Nullable 
  private String parseDriveRoot(String path) {
    Matcher drivePathMatcher = DRIVE_LETTER_ROOT.matcher(path);
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
  } 
 
  private static void checkValid(String path) {
    int nulIndex = path.indexOf('\0');
    if (nulIndex != -1) {
      throw new InvalidPathException(path, "nul character not allowed", nulIndex);
    } 
  } 
 
  @Override 
  public String toString(@Nullable String root, Iterable<String> names) {
    StringBuilder builder = new StringBuilder();
    if (root != null) {
      builder.append(root);
    } 
    joiner().appendTo(builder, names);
    return builder.toString();
  } 
 
  @Override 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getIndex
  public void testUnix_illegalCharacters() { 
    try { 
      PathType.unix().parsePath("/foo/bar\0"); 
      fail(); 
    } catch (InvalidPathException expected) {
      assertEquals(8, expected.getIndex());
    } 
 
    try { 
      PathType.unix().parsePath("/\u00001/foo"); 
      fail(); 
    } catch (InvalidPathException expected) {
      assertEquals(1, expected.getIndex());
    } 
  } 
} 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 InvalidPathException Methods: