java - Validate String input COULD be a valid path -


i wish validate string path. don't want check path exists or create path (that includes create + delete), wish check input string validate path on executing system.

so far have been messing file class no luck. expect following fail on osx machine doesn't:

file f = new file("!@£$%^&*()±§-_=+[{}]:;\"'|>.?/<,~`±"); system.out.println(f.getcanonicalpath()); 

is there me?

you can via regex: file path validation in javascript

or checking if parent of path exists: is there way in java determine if path valid without attempting create file?

just note path depends on os: https://serverfault.com/questions/150740/linux-windows-unix-file-names-which-characters-are-allowed-which-are-unesc

also, because path valid, doesn't mean file can written there. example, in linux, need super user write /usr/


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -