java - .getNameCount() different results when creating Path using String and URI -


i reading book related ocp exam. studying path , uri , noticed strange. here code:

    uri u1 = new uri("file://c:/brother/drvlangchg/langlist.ini");     path f = paths.get("c:/brother/drvlangchg/langlist.ini");     path p1 = paths.get(u1);     for(int = 0; < p1.getnamecount(); i++) {         system.out.print(p1.getname(i) + " ");     }     system.out.println(p1.getroot());     system.out.println();     for(int = 0; < f.getnamecount(); i++) {         system.out.print(f.getname(i)+" ");     }     system.out.println(p1.getroot()); 

and output:

drvlangchg langlist.ini \c\brother\

brother drvlangchg langlist.ini \c\brother\

what noticed internally java sets type "file" when using uri while type null string parameter (i on windows 10).

i little puzzled , learn more strange (in opinion) behavior , should watch if using path.

edit:got it, comments.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -