如何在 OBEX 中使用 FTP 通过蓝牙 java 代码删除文件并将其复制到目标设备?
我需要通过蓝牙在目标设备中将文件替换为旧版本。 我知道为此需要使用 OBEX(FTP 和 OPP)配置文件。 但我不知道如何删除旧版本并在目标目录中复制新版本的文件(java代码)。
你能帮我吗?
I need to replace a file with old version of it in destination device via bluetooth.
I know that OBEX(FTP and OPP) profiles is necessary to use for this.
But I don't know How can delete old version and copy new version of file in destination directory (java code).
Can you help me please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

要对文件执行操作,您首先需要更改到文件所在的目录。
例如,如果您需要访问 /root/directory/subdir/
你应该调用setPath 3次
下面所有的代码都是针对J2ME的
我使用此方法来设置带分隔符的路径(例如/root/dir/)。
要删除文件,您应该在其上打开 PUT 操作并关闭它,或者使用 ClientSession 中的删除方法。
如果您需要替换文件,您可能不需要调用删除方法,只需打开 OutputStream 并向其写入一个新文件,
记住在完成流后关闭操作。
To perform operations on files you whould firstly change to the directory where the file is.
For exampe, if you need to get to /root/directory/subdir/
you should call setPath three times
All the code written below is for J2ME
I use this method to set the path with separators (e.g. /root/dir/)
To delete a file you should open a PUT operation on it and close it, or use the delete method in ClientSession.
If you need to replace a file you probably don't need to call delete method, just open OutputStream and write to it a new one
remember to close Operation after you done with the streams.