我的机器上本地很少有 excel 文件。我想将此excel文件上传到ftp。我正在使用 apache commons FTPClinet。但是当它上传文件时,它已损坏并且大小为零。这是示例程序
谁能指出我在哪里做错了?
public class App {
private static final String server = "localhost";
private static final String username = "test";
private static final String password = "test";
private static final String directory = "/home/files";
public static void main(String[] args) throws SocketException, IOException {
FTPClient f = new FTPClient();
f.connect(server);
f.login(username, password);
f.setFileType(FTPClient.BINARY_FILE_TYPE);
InputStream is = null;
is = new FileInputStream("c:\\tmp\\output.xls");
Boolean isStored = f.storeFile("status.xls", is);
is.close();
}
}