如何以编程方式列出本地目录中的已装入文件?

时间:2015-06-04 05:48:21

标签: java android samba

我正在使用samba共享安装网络。打开后安装并查看文件浏览器后,网络文件显示在已安装的文件夹中。但是当我调用directory.listFiles();时,它无法以编程方式显示文件。

这是我的代码......

Main.java;

String mountFilePath1 = "//10.0.0.18/BeagleBoneBlack/JackSongs";
try{
            Process su = Runtime.getRuntime().exec("su");
            DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());
            outputStream.writeBytes("umount /data/test/ \n  chmod -R 777  /data/test/ \n mount -t cifs -o user=root,pass=guest,nounix,noserverino " + mountFilePath1 + "   /data/test/\n");
            outputStream.flush();
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }catch(IOException e){}

此后我检查/ data / test目录文件显示...但是当我打电话

  File directory = new file("/data/test/");
  File[] filesList = directory.listFiles();

它没有显示任何异常并导致应用程序崩溃.. 日志详细信息是......

06-04 11:15:34.866    4188-4188/? E/cutils-trace﹕ Error opening trace file: Permission denied (13)
06-04 11:15:35.056    4188-4188/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
06-04 11:15:35.056    4188-4188/? E/android.os.Debug﹕ failed to load memtrack module: -2
06-04 11:15:41.716      479-509/? E/InputDispatcher﹕ channel '422e9b30 amiTechnologies.products.multizoneplayer/view.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
06-04 11:15:53.316      479-502/? E/JavaBinder﹕ !!! FAILED BINDER TRANSACTION !!!
06-04 11:15:54.486    4558-4558/? E/cutils-trace﹕ Error opening trace file: Permission denied (13)
06-04 11:15:54.616    4558-4558/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
06-04 11:15:54.616    4558-4558/? E/android.os.Debug﹕ failed to load memtrack module: -2
06-04 11:15:55.326      891-891/? E/NetworkScheduler.SchedulerReceiver﹕ Invalid parameter app
06-04 11:15:55.326      891-891/? E/NetworkScheduler.SchedulerReceiver﹕ Invalid package name : Perhaps you didn't include a PendingIntent in the extras?
06-04 11:15:57.036    4733-4733/? E/cutils-trace﹕ Error opening trace file: No such file or directory (2)
06-04 11:15:57.176    4733-4733/? E/memtrack﹕ Couldn't load memtrack module (No such file or directory)
06-04 11:15:57.176    4733-4733/? E/android.os.Debug﹕ failed to load memtrack module: -2

0 个答案:

没有答案