【发布时间】:2011-06-21 01:48:26
【问题描述】:
我正在使用 Ganymed API sftp 进入 Unix 服务器。我可以在服务器中创建文件,但文件的内容总是空的。
Ganymed API 位置: http://www.ganymed.ethz.ch/ssh2/
代码:
function (ByteArrayOutputStream reportBytes){
// reportBytes is a valid ByteArrayOutputStream
// if I write it to a file in to a local directory using reportBytes.writeTo(fout);
// I can see the contents */
byte byteArray[]=reportBytes.toByteArray();
SFTPv3FileHandle SFTPFILEHandle=sftpClient.createFileTruncate("test.txt");
//The file is created successfully and it is listed in unix
// The permissions of the file -rw-r--r-- 1 test.txt
sftpClient.write(SFTPFILEHandle, 0, byteArray, 0,byteArray.length );
//The above line doesnt seem to work, the file is always empty
}
/* write function definition is */
public void write(SFTPv3FileHandle handle, long fileOffset, byte[] src, int srcoff, int len) throws IOException
如果我在这里做错了什么,有人可以告诉我
【问题讨论】:
-
您是否确认可以通过使用另一个 SFTP 客户端进行测试来将文件上传到此服务器?也许您的帐户有权创建文件但没有写入文件的权限...