我们如何获得不同文件系统使用的文件分隔符? [英] How do we get the file separators used by the different file systems?

查看:148
本文介绍了我们如何获得不同文件系统使用的文件分隔符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午好,

据我所知,Android有(至少)2个文件系统。一个是内部存储(例如/数据和/系统),另一个是外部存储(例如/ mnt / sdcard),

这意味着当我们将文件保存到内部存储( Context.getFilesDir Context.getCacheDir ),使用的文件分隔符可能与将文件保存到外部存储时不同( Context.getExternalFilesDir Context.getExternalCacheDir Environment.getExternalStoragePubli cDirectory ),但 java.io.File.separator 似乎只给了我们关于默认文件系统的信息。



我们如何获得Android上不同文件系统使用的不同文件分隔符? p>

我试过 java.nio.file.spi.FileSystemProvider.installedProviders(),但它看起来像 android没有这个包

有没有办法获得Android上的文件系统列表根据我的理解,Android(至少)有2个文件系统。一个是内部存储(例如/ data和/ system),另一个是外部存储(例如/ mnt / sdcard),

这对于Android 1.x和2.x是准确的。从Android 3.0开始,外部存储只是内部存储的一个目录。
$ b


这意味着当我们将文件保存到内部存储(Context.getFilesDir,Context.getCacheDir),所使用的文件分隔符可能不同于我们将文件保存到外部存储时的情况。当然不是。分隔符是操作系统的功能,而不是文件系统。


有没有办法在Android上获取文件系统列表?

p>

没有任何支持。 SDK应用程序应该只使用内部和外部存储,如通过您在答案中引用的API。


嗯,我听说过在NTFS上挂载外部驱动器,这就是为什么我认为它们可以不同


你错了。文件和路径分隔符与文件系统的格式无关。


然而,它不只是文件分隔符,文件分隔符路径分隔符)在不同的文件系统之间也是不同的。

你错了。文件和路径分隔符与文件系统的格式无关。


Good afternoon all,

From what I understand, Android has (at least) 2 file systems. One is for "internal" storage (e.g. /data and /system) and the other for "external" storage (e.g. /mnt/sdcard),

This implies that when we save files to "internal" storage (Context.getFilesDir, Context.getCacheDir), the file separator used may be different from when we save files to "external" storage (Context.getExternalFilesDir, Context.getExternalCacheDir, Environment.getExternalStoragePublicDirectory), yet java.io.File.separator only seems to give us information on the "default" filesystem used.

How do we get the different file separators used by the different file systems on Android?

I've tried java.nio.file.spi.FileSystemProvider.installedProviders() but it looks like android doesn't have this package.

Is there anyway to get a list of filesystems on Android?

解决方案

From what I understand, Android has (at least) 2 file systems. One is for "internal" storage (e.g. /data and /system) and the other for "external" storage (e.g. /mnt/sdcard),

That was accurate for Android 1.x and 2.x. As of Android 3.0, external storage is merely a directory inside of internal storage.

This implies that when we save files to "internal" storage (Context.getFilesDir, Context.getCacheDir), the file separator used may be different from when we save files to "external" storage

Of course not. Separators are a feature of an operating system, not a file system.

Is there anyway to get a list of filesystems on Android?

Nothing that is supported. SDK applications should only use internal and external storage, such as via the APIs you cited in your answer.

Hmm, I've heard of mountaing the external drive on a NTFS which is why I think that they can be different

You are mistaken. File and path separators have nothing to do with the format of the file system.

However its not just the file separators, the file delimiters (path separators) are also different between different file systems.

You are mistaken. File and path separators have nothing to do with the format of the file system.

这篇关于我们如何获得不同文件系统使用的文件分隔符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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