I have an Ftplet where I want to execute my code when the user uploads(
put sample.txt) a file. I want to read the file (not to store) and
based on the contents do a bunch of stuff. I have something like this in
my code:
public FtpletEnum onUploadStart(FtpSession session, FtpRequest request,
FtpReplyOutput response)
throws FtpException, IOException
{
String file =request.getArgument();
try{
//get the file input stream
FileInputStream fis = new FileInputStream(file);
//read the first 200 bytes of the file
byte[] buf= new byte[200];
fis.read(buf, 0,200)
}catch(Exception ex){}
}
Now, I am sure this not the correct way to read such a file. The
Dataconnection object as obtained by
session.getDataConnection().openConnection() has a transferFromClient()
method, but I assume it transfers the whole file on to the server.
Any help is greately appreciated.
Thanks
Ajith