Natürlich geht das mit Java
Man kann sich mit Java auf einem bestimmten FTP server einloggen soweit man den Benutzernamen un sein Kennwort kennt. Dazu gibts im Internet diverse fertige Klassen wo man nurnoch ein paar zeilen in seinem eigenen Programm tippen muss um z.B. eine Datei hoch oder runterzuladen!!!
Ich hab hier mal so ne externe Klasse (GEHÖRT NICHT MIER):
/**
* File: FTPConnection.java
* Author: Bret Taylor <btaylor@cs.stanford.edu>
* ---------------------------------------------
* $Id$
* ---------------------------------------------
* Parts of this code were adopted from a variety of other FTP classes the
* author has encountered that he was not completely satisfied with. If you
* think more thanks are due to any particular author than is given, please
* let him know. With that caveat, this class can be freely distributed and
* modified as long as Bret Taylor is given credit in the source code comments.
*/
import java.io.*;
import java.net.*;
import java.util.*;
/**
* <p>A wrapper for the network and command protocols needed for the most common
* FTP commands. Standard usage looks something like this:</p>
* <pre> FTPConnection connection = new FTPConnection();
* try {
* if (connection.connect(host)) {
* if (connection.login(username, password)) {
* connection.downloadFile(serverFileName);
* connection.uploadFile(localFileName);
* }
* connection.disconnect();
* }
* } catch (UnknownHostException e) {
* // handle unknown host
* } catch (IOException e) {
* // handle I/O exception
* }</pre>
* <p>Most FTP commands are wrapped by easy-to-use methods, but in case clients
* need more flexibility, you can execute commands directly using the methods
* <a href="#executeCommand(java.lang.String)">executeCommand</a> and
* <a href="#executeDataCommand(java.lang.String, java.i
utputStream)">executeDataCommand</a>,
* the latter of which is used for commands that require an open data port.</p>
*
* @author Bret Taylor
* @version 1.0
*/
public class FTPConnection extends Object {
/**
* If this flag is on, we print out debugging information to stdout during
* execution. Useful for debugging the FTP class and seeing the server's
* responses directly.
*/
private static boolean PRINT_DEBUG_INFO = false;
/**
* Connects to the given FTP host on port 21, the default FTP port.
*/
public boolean connect(String host)
throws UnknownHostException, IOException
{
return connect(host, 21);
}
/**
* Connects to the given FTP host on the given port.
*/
public boolean connect(String host, int port)
throws UnknownHostException, IOException
{
connectionSocket = new Socket(host, port);
outputStream = new PrintStream(connectionSocket.getOutputStream());
inputStream = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
if (!isPositiveCompleteResponse(getServerReply())){
disconnect();
return false;
}
return true;
}
/**
* Disconnects from the host to which we are currently connected.
*/
public void disconnect()
{
if (outputStream != null) {
try {
outputStream.close();
inputStream.close();
connectionSocket.close();
} catch (IOException e) {}
outputStream = null;
inputStream = null;
connectionSocket = null;
}
}
/**
* Wrapper for the commands <code>user [username]</code> and <code>pass
* [password]</code>.
*/
public boolean login(String username, String password)
throws IOException
{
int response = executeCommand("user " + username);
if (!isPositiveIntermediateResponse(response)) return false;
response = executeCommand("pass " + password);
return isPositiveCompleteResponse(response);
}
/**
* Wrapper for the command <code>cwd [directory]</code>.
*/
public boolean changeDirectory(String directory)
throws IOException
{
int response = executeCommand("cwd " + directory);
return isPositiveCompleteResponse(response);
}
/**
* Wrapper for the commands <code>rnfr [oldName]</code> and <code>rnto
* [newName]</code>.
*/
public boolean renameFile(String oldName, String newName)
throws IOException
{
int response = executeCommand("rnfr " + oldName);
if (!isPositiveIntermediateResponse(response)) return false;
response = executeCommand("rnto " + newName);
return isPositiveCompleteResponse(response);
}
/**
* Wrapper for the command <code>mkd [directory]</code>.
*/
public boolean makeDirectory(String directory)
throws IOException
{
int response = executeCommand("mkd " + directory);
return isPositiveCompleteResponse(response);
}
/**
* Wrapper for the command <code>rmd [directory]</code>.
*/
public boolean removeDirectory(String directory)
throws IOException
{
int response = executeCommand("rmd " + directory);
return isPositiveCompleteResponse(response);
}
/**
* Wrapper for the command <code>cdup</code>.
*/
public boolean parentDirectory()
throws IOException
{
int response = executeCommand("cdup");
return isPositiveCompleteResponse(response);
}
/**
* Wrapper for the command <code>dele [fileName]</code>.
*/
public boolean deleteFile(String fileName)
throws IOException
{
int response = executeCommand("dele " + fileName);
return isPositiveCompleteResponse(response);
}
/**
* Wrapper for the command <code>pwd</code>.
*/
public String getCurrentDirectory()
throws IOException
{
String response = getExecutionResponse("pwd");
StringTokenizer strtok = new StringTokenizer(response);
// Get rid of the first token, which is the return code
if (strtok.countTokens() < 2) return null;
strtok.nextToken();
String directoryName = strtok.nextToken();
// Most servers surround the directory name with quotation marks
int strlen = directoryName.length();
if (strlen == 0) return null;
if (directoryName.charAt(0) == '\"') {
directoryName = directoryName.substring(1);
strlen--;
}
if (directoryName.charAt(strlen - 1) == '\"')
return directoryName.substring(0, strlen - 1);
return directoryName;
}
/**
* Wrapper for the command <code>syst</code>.
*/
public String getSystemType()
throws IOException
{
return excludeCode(getExecutionResponse("syst"));
}
/**
* Wrapper for the command <code>mdtm [fileName]</code>. If the file does
* not exist, we return -1;
*/
public long getModificationTime(String fileName)
throws IOException
{
String response = excludeCode(getExecutionResponse("mdtm " + fileName));
try {
return Long.parseLong(response);
} catch (Exception e) {
return -1L;
}
}
/**