正斜杠还是反斜杠? [英] Forward slash or backslash?

查看:260
本文介绍了正斜杠还是反斜杠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找写入和从(分别)不同于我的程序目录的文本文件。当我指定要写入或读取的目录时,应该使用正斜杠还是反斜线来标识文件路径? 解决方案

使用正斜杠会使系统独立。为了简单,我坚持这一点。



考虑使用 java.io.File.separator ,如果您曾经显示过用户的路径。你宁愿不惊讶那些Windows用户。他们是一个跳动很多。


I am looking to write and read text files to and from (respectively) a directory different from that of my program. When I specify a directory to write to or read from, should I be using forward slashes or backslashes to identify a file path?

解决方案

Using forward slashes will make it system independent. I'd stick to that for simplicity.

Consider using java.io.File.separator if you ever display the path to the user. You'd rather not surprise those Windows users. They're a jumpy lot.

这篇关于正斜杠还是反斜杠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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