android目录末尾有奇怪的字符
我在 Android 中创建目录时遇到问题。我使用此代码创建一个目录(如果不存在),然后在其下创建一个文件。
dir=new File(Constants.TASK_DIRECTORY);
if(!dir.exists())
dir.mkdirs();
file=new File(dir, FILENAME);
file.createNewFile();
有时它工作正常,但有时当我从 adb shell 检查文件夹时,我会看到以 3 个或更多 "|"
字符结尾的目录。我的目录名称格式是 “Abc_123-10.10.2000”
。我有时看到的是完全相同的,但有时是 "Abc_123-10.10.2000|||"
。我需要借助名称格式来访问目录下的文件,但这种情况使其变得困难,任何帮助将不胜感激。
我在此代码应用程序中设置 TASK 目录
Constants.TASK_DIRECTORY=getFilesDir()+"/"+app.getUserName()+"-"+dt;
是我的应用程序对象
编辑:解决了此问题,这是因为 TASK_DIRECTORY 未正确设置并包含“|”人物。但这怎么可能呢?
I have an issue with directory creation in Android. I use this code to create a directory if doesn't exist and then create a file under it.
dir=new File(Constants.TASK_DIRECTORY);
if(!dir.exists())
dir.mkdirs();
file=new File(dir, FILENAME);
file.createNewFile();
Sometimes it works fine, but sometimes when I check the folder from adb shell I see directories ending with 3 or more "|"
characters. My directory name format is"Abc_123-10.10.2000 "
. What I see sometimes is exactly the same, but sometimes "Abc_123-10.10.2000|||"
. I need to access the files under directories with the help of their name format but this situation makes it hard, any help would be appreciated.
I set TASK directory in this code
Constants.TASK_DIRECTORY=getFilesDir()+"/"+app.getUserName()+"-"+dt;
app is my application object
Edit: Solved this problem, it was because TASK_DIRECTORY was not properly set and contains "|" characters. But how can this be possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文件无法存储或保存某些特殊字符,如下所示。
File can't store or save with some special character as below.