请教关于使用InputStream下载文件的问题,下边是我做的一个下载文件的操作:
public byte[] downLoad(String filename) throws RemoteException {
System.out.println("  in download ");
File file=new File(localSharedDir+"\\"+filename);

if(!file.exists()){

throw new RemoteException("the file whose name is " + filename + " not existed ");
}
try {
InputStream is = new FileInputStream(file);
buffer = new byte[(int)file.length()];
is.read(buffer);
is.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return buffer;
}这是一个下载程序的服务器端的代码,我想在判断文件不存在时,发给客服端一个0字节的数据,这样客服端判断文件不存在,小弟不知道下边的应该如何写:
if(!file.exists()){

throw new RemoteException("the file whose name is " + filename + " not existed ");
有人意见是做个转发页面,我想写一个更简单的方法。