【问题标题】:smb file writing in local drive from network drive is not working从网络驱动器写入本地驱动器的 smb 文件不起作用
【发布时间】:2014-12-28 04:36:36
【问题描述】:

我正在尝试在我的本地驱动器中写入一个文件,该文件在服务器上的网络驱动器中可用。我可以写这个图像,甚至可以看到可用文件的大小。但是,当我打开文件时,它说预览不可用。文件内容不来。

我读取网络文件的代码

SmbFileInputStream sfis = null;
sfis = new SmbFileInputStream(serverFile);
fileBytes = new byte[(int) serverFile.length()];
sfis.read(fileBytes);

我在本地驱动器中写入文件的代码

FileOutputStream fos;
fos = new FileOutputStream(tempFile);
fos.write(fileBytes);

我还尝试使用 file.copyTo 方法,将我的本地文件提供为 smbfile。

serverFile.copyTo(ss);

【问题讨论】:

  • 您可能没有关闭或刷新文件
  • 实际上我的代码中有它们,这里没有复制。我有冲洗和关闭的写作部分。

标签: java file-io java-io smb file-writing


【解决方案1】:

我想通了,它工作正常。

将前两行改为

InputStream sfis = new SmbFileInputStream(serverFile);

真正的变化是变量的引用现在是

InputStream

【讨论】:

    猜你喜欢
    • 2021-12-21
    • 2019-11-14
    • 2016-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多