我们用Axis WS发送文件到Server时,当文件到达服务器时,无法删除本地的原文件。这个问题可以通过复写FileDataSource类来解决。
复写的FileDataSource类为:
reference:[url]http://markmail.org/message/hum5yyflnooco426[/url]
复写的FileDataSource类为:
import java.io.File;
import java.io.InputStream;
import javax.activation.FileDataSource;
public class MyFileDataSource extends FileDataSource {
private InputStream is;
private boolean firstCall;
public MyFileDataSource(File file) {
super(file);
firstCall = true;
}
public InputStream getInputStream() throws java.io.IOException {
if (firstCall) {
this.is = super.getInputStream();
firstCall = false;
}
return is;
}
}
reference:[url]http://markmail.org/message/hum5yyflnooco426[/url]