Will forward slash work across platforms in Path.resolve?

John Freeman

Since Path.resolve does not accept an array of strings, it is possible pass a relative path containing multiple path components, e.g. "foo/bar/baz".

My question is

if the forward slash in such a relative path will work as intended across platforms?

I have seen some answers on here that allege Java treats forward slashes as a "universal separator", but not citations to support them.

aioobe

/ should be a valid path separator on all major platforms of today. See for instance File.separator vs Slash in Paths (maybe it's even a dup?)

If you're the pedantic type you can use FileSystem.getSeparator.

Note that you can also do

root.resolve(Paths.get("foo", "bar", "baz"));

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Spring MVC, pattern doesn't work properly in case of forward slash symbol in path variable

분류에서Dev

What happens to the second forward slash?

분류에서Dev

Forward slash not detected in "grep" command

분류에서Dev

Is Double Math Consistent across Multiple Platforms?

분류에서Dev

Replace backslash("\") with forward slash("/") in a variable in bash

분류에서Dev

Search pattern containing forward slash using AWK

분류에서Dev

Sass 3.4 Removing forward slash on a string

분류에서Dev

Escaping the slash in r does not work

분류에서Dev

PATH, resolve location of exe

분류에서Dev

Batch - Resolve relative path

분류에서Dev

Replacing backslash with double backslash or forward slash in LPSTR filepath

분류에서Dev

MySQLI- Allow the Forward Slash to be Used With Insert Statement

분류에서Dev

Failed to find Platform SDK with path: platforms;android-R

분류에서Dev

How use Forward declaration in clojure and unbound variables across namespace

분류에서Dev

Could not resolve SDK path for 'macosx10.10'

분류에서Dev

How to resolve a relative directory path to canonical path in MATLAB/Octave

분류에서Dev

firewall-cmd - add-forward-port don't work

분류에서Dev

How can i resolve the path laocation in batch file

분류에서Dev

Cannot resolve all property references in the property path 'TextElement.Foreground'

분류에서Dev

Nodejs path.resolve가 정의되지 않았습니다.

분류에서Dev

Python은 JS path.resolve ()와 동일합니까?

분류에서Dev

Resolve-Path cmdlet의 기능은 정확히 무엇입니까?

분류에서Dev

stream_resolve_include_path가 false를 반환합니까?

분류에서Dev

How to change the include_path Zend frame work in linux cpanel?

분류에서Dev

How to make Reachability.m in iOS to work with the full path of the resource?

분류에서Dev

Flat list of work items with restriction on parent's Iteration path

분류에서Dev

Bash completion won't work if calling application with the absolute path

분류에서Dev

How do `/etc/hosts` and DNS work together to resolve hostnames to IP addresses?

분류에서Dev

ModelAndView forward

Related 관련 기사

  1. 1

    Spring MVC, pattern doesn't work properly in case of forward slash symbol in path variable

  2. 2

    What happens to the second forward slash?

  3. 3

    Forward slash not detected in "grep" command

  4. 4

    Is Double Math Consistent across Multiple Platforms?

  5. 5

    Replace backslash("\") with forward slash("/") in a variable in bash

  6. 6

    Search pattern containing forward slash using AWK

  7. 7

    Sass 3.4 Removing forward slash on a string

  8. 8

    Escaping the slash in r does not work

  9. 9

    PATH, resolve location of exe

  10. 10

    Batch - Resolve relative path

  11. 11

    Replacing backslash with double backslash or forward slash in LPSTR filepath

  12. 12

    MySQLI- Allow the Forward Slash to be Used With Insert Statement

  13. 13

    Failed to find Platform SDK with path: platforms;android-R

  14. 14

    How use Forward declaration in clojure and unbound variables across namespace

  15. 15

    Could not resolve SDK path for 'macosx10.10'

  16. 16

    How to resolve a relative directory path to canonical path in MATLAB/Octave

  17. 17

    firewall-cmd - add-forward-port don't work

  18. 18

    How can i resolve the path laocation in batch file

  19. 19

    Cannot resolve all property references in the property path 'TextElement.Foreground'

  20. 20

    Nodejs path.resolve가 정의되지 않았습니다.

  21. 21

    Python은 JS path.resolve ()와 동일합니까?

  22. 22

    Resolve-Path cmdlet의 기능은 정확히 무엇입니까?

  23. 23

    stream_resolve_include_path가 false를 반환합니까?

  24. 24

    How to change the include_path Zend frame work in linux cpanel?

  25. 25

    How to make Reachability.m in iOS to work with the full path of the resource?

  26. 26

    Flat list of work items with restriction on parent's Iteration path

  27. 27

    Bash completion won't work if calling application with the absolute path

  28. 28

    How do `/etc/hosts` and DNS work together to resolve hostnames to IP addresses?

  29. 29

    ModelAndView forward

뜨겁다태그

보관