I would like to know how to determine whether string is valid file path.
The file path may or may not exist.
You can't really be sure until you try to create that file. Maybe the path is valid but the security settings won't allow creation of the file. The only instance that could tell you if the path is REALLY valid would be the OS, so why don't you try to create that file an catch the IOException
which indicates it's not valid? In my humble opinion, this is an approach: Assume the input is valid, use it, and catch an IOException
when it isn't valid.