Example usage for java.nio.file InvalidPathException getIndex

List of usage examples for java.nio.file InvalidPathException getIndex

Introduction

In this page you can find the example usage for java.nio.file InvalidPathException getIndex.

Prototype

public int getIndex() 

Source Link

Document

Returns an index into the input string of the position at which the error occurred, or -1 if this position is not known.

Usage

From source file:Test.java

public static void main(String[] args) {
    try {//  ww w.  j  a va 2  s .c  o  m
        Path path = Paths.get("/home\0", "docs", "users.txt");
        System.out.println("Absolute path: " + path.toAbsolutePath());
    } catch (InvalidPathException ex) {
        System.out.println("Bad path: [" + ex.getInput() + "] at position " + ex.getIndex());
    }

}