什么时候应该使用File.separator?什么时候应该使用File.pathSeparator? [英] When should I use File.separator and when File.pathSeparator?
问题描述
在File
类中,有两个字符串, pathSeparator
.
In the File
class there are two strings, separator
and pathSeparator
.
有什么区别?我什么时候应该在另一个上使用?
What's the difference? When should I use one over the other?
推荐答案
如果您指的是File.separator
和File.pathSeparator
,则:
-
File.pathSeparator
用于在文件路径列表中分隔各个文件路径.考虑在Windows上的PATH环境变量.您使用;
分隔文件路径,因此在WindowsFile.pathSeparator
上将是;
.
File.pathSeparator
is used to separate individual file paths in a list of file paths. Consider on windows, the PATH environment variable. You use a;
to separate the file paths so on WindowsFile.pathSeparator
would be;
.
File.separator
是/
或\
,用于将路径拆分到特定文件.例如,在Windows上,它是\
或C:\Documents\Test
File.separator
is either /
or \
that is used to split up the path to a specific file. For example on Windows it is \
or C:\Documents\Test
这篇关于什么时候应该使用File.separator?什么时候应该使用File.pathSeparator?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!