什么时候应该使用File.separator?什么时候应该使用File.pathSeparator? [英] When should I use File.separator and when File.pathSeparator?

查看:131
本文介绍了什么时候应该使用File.separator?什么时候应该使用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.separatorFile.pathSeparator,则:

  • File.pathSeparator用于在文件路径列表中分隔各个文件路径.考虑在Windows上的PATH环境变量.您使用;分隔文件路径,因此在Windows File.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 Windows File.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆