azsat
asked on
Reading individual fields in an FTP input Stream
Hi I have a java method which uses a streaming FTP connection to a remote file. My problem is that I do not know
how split the buffer read in into individual fileds so I can manipulate them. The code is as follows:
NB I have entered another related question to this problem recently, but that requires more comprehensive design details and this one is specific to geting the data from the input stream.
public static boolean getDataFiles( String _host,String _user,String _password,String destinationFolder,String strDate) {
try
{
String host= _host; String user= _user; String password= _password;
URLConnection urlc = null;
String targetfile= ""Data" + strDate + "_v4.dat";
URL url = new URL("ftp://"+ user+ ":"+ password+ "@"+ host+ "/"+ targetfile+ ";type=i");
urlc = url.openConnection();
urlc.setDoInput(true);
InputStream is = urlc.getInputStream();
byte[] buf= new byte[16384];
for(int br = is.read(buf); br > -1; br = is.read(buf))
{
//**** get individual fields from buffer delimited by comma***
//System.out.write(buf, 0 , br);
}
is.close();
}
catch (Exception E)
{
System.err.println(E.getMe
E.printStackTrace();
}
return true;
}
Thanks
azsat
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
glad to help :-)