为什么在Android中使用File.separator? [英] Why is File.separator in Android using?

查看:210
本文介绍了为什么在Android中使用File.separator?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

许多项目都使用File.separator作为路径分隔符.但是,为什么要在Android上使用它呢?我知道它在跨平台应用程序中很有用,在这些应用程序中Windows使用\作为分隔符,而Linux使用/作为分隔符,但是开发人员真的认为Android项目将来会在Windows上启动吗?有历史原因吗?显然,使用/代替File.separator更有用,甚至可以将它添加到像fileSepfs这样的变量中.

There's many projects which are using File.separator as path separators. But why do it's using on Android? I know that it can be useful on cross-platform apps, where Windows using \, and Linux using / as a separators, but are developers really think that Android projects will be launch on Windows in future, or is it only an historical reasons? Obviously, that it's more useful to use / instead of File.separator, even to add it to the variable like fileSep or fs.

谢谢!

推荐答案

Android在Linux之上运行.因此,所有文件分隔符和类似设置都使用与Linux相同的文件.使用File.separator的人们正在运行(或复制)旨在实现多平台的Java代码,或者非常谨慎.

Android runs on top of Linux. So all file separators and similar settings use the same as Linux. People using File.separator are either running (or copying) Java code meant to be multi-platform, or are being extremely cautious.

这篇关于为什么在Android中使用File.separator?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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