Hi all,
I am trying to read a
java class to ftp files but after I write the file, it always has some annoying leading characters (6 to 8 chars), how to fix it. here is the code
****************
import java.net.*;
import java.io.*;
import sun.net.ftp.*;
import sun.net.TelnetInputStream;
class FTP2{
public static void main(
String args[]){
try{
URL url = new URL("ftp://username

assword@hostname/path/filename");
URLConnection conn = url.openConnection();
// Read from the connection
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
StringBuffer sb= new StringBuffer();
while ((line = in.readLine()) != null){
System.out.println(line);
sb = sb.append(line);
}
in.close();
try{
File fileName= new File("index.html");
ObjectOutputStream output;
output = new ObjectOutputStream(new FileOutputStream(fileName));
output.writeObject(sb.toString());
output.flush();
}catch(IOException e){
}
}catch(Exception e){
}
}
}