How to parse this string in Java?

前端 未结 10 1380
感情败类
感情败类 2020-11-29 05:19

prefix/dir1/dir2/dir3/dir4/..

How to parse the dir1, dir2 values out of the above string in Java?

The prefix here c

10条回答
  •  情深已故
    2020-11-29 05:43

    If it's a File, you can get the parts by creating an instanceof File and then ask for its segments.

    This is good because it'll work regardless of the direction of the slashes; it's platform independent (except for the "drive letters" in windows...)

提交回复
热议问题