将文件从 Samba 驱动器复制到 Android SD 卡目录
我是 Android 和 Samba 新手。我正在尝试使用 JCIFS 副本。将文件从 Samba 目录复制到 Android 3.1 设备上 sdcard 下的“下载”目录的方法。以下是我的代码:
from = new SmbFile("smb://username:[email protected]/sandbox/sambatosdcard.txt");
File root = Environment.getExternalStorageDirectory();
File sourceFile = new File(root + "/Download", "SambaCopy.txt");
to = new SmbFile(sourceFile.getAbsolutePath());
from.copyTo(to);
我在“to”文件上收到 MalformedURLException。有没有办法使用 copyTo 方法来解决此问题,或者是否有其他方法可以使用 JCIFS 或任何其他方式将文件从 samba 文件夹复制到 sdcard 文件夹?谢谢。
I am new to Android and Samba. I am trying to use the JCIFS copy. To method to copy a file from a Samba directory to the 'Download' directory under sdcard on an Android 3.1 device. Following is my code:
from = new SmbFile("smb://username:[email protected]/sandbox/sambatosdcard.txt");
File root = Environment.getExternalStorageDirectory();
File sourceFile = new File(root + "/Download", "SambaCopy.txt");
to = new SmbFile(sourceFile.getAbsolutePath());
from.copyTo(to);
I am getting a MalformedURLException on the 'to' file. Is there a way to get around this problem using the copyTo
method, or is there an alternate way to copy a file from the samba folder to the sdcard folder using JCIFS or any other way? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SmbFile 的
copyTo()
方法允许您在网络之间复制文件。要在本地设备和网络之间复制文件,您需要使用流。例如:The SmbFile's
copyTo()
method lets you copy files from network to network. To copy files between your local device and the network you need to use streams. E.g.: