本文整理汇总了Java中it.sauronsoftware.ftp4j.FTPException类的典型用法代码示例。如果您正苦于以下问题:Java FTPException类的具体用法?Java FTPException怎么用?Java FTPException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FTPException类属于it.sauronsoftware.ftp4j包,在下文中一共展示了FTPException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listFiles
import it.sauronsoftware.ftp4j.FTPException; //导入依赖的package包/类
/**
* Lists the files present at the specified path.
* @param path The specified path.
* @return The list of files.
*/
public List<FileEntity> listFiles(FtpServer server, String path) throws FTPException, IOException, FTPIllegalReplyException, FTPAbortedException, FTPDataTransferException, FTPListParseException {
FTPClient client = this.getConnection(server);
if(path != null && !path.equals("/")) {
client.changeDirectory(path);
}
FTPFile[] list = client.list();
List<FileEntity> results = new ArrayList<FileEntity>();
if(list != null) {
for (FTPFile file : list) {
if(!file.getName().equals("..")) {
results.add(this.ftpFileToEntity(file, path));
}
}
}
Collections.sort(results);
return results;
}
示例2: retrieveFile
import it.sauronsoftware.ftp4j.FTPException; //导入依赖的package包/类
/**
* Speichert den Remote-File im OutputStream local.
*/
private static void retrieveFile (String remote, OutputStream local, FtpConnection con)
throws IOException, FTPIllegalReplyException, FTPException, IllegalStateException,
FTPDataTransferException, FTPAbortedException
{
boolean conWasNull = con == null;
if (conWasNull)
con = cons.getClient();
FTPClient client = con.getFtpClient();
try
{
client.download(remote, local, 0, null);
}
finally
{
if (conWasNull)
con.setBusy(false);
}
local.close();
}
示例3: storeFile
import it.sauronsoftware.ftp4j.FTPException; //导入依赖的package包/类
/**
* Lädt den Inhalt des InputStreams local nach remote.
*/
private static void storeFile (String remote, InputStream local, FtpConnection con)
throws IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException
{
boolean conWasNull = con == null;
if (conWasNull)
con = cons.getClient();
FTPClient client = con.getFtpClient();
try
{
client.upload(remote, local, 0, 0, null);
}
finally
{
if (conWasNull)
con.setBusy(false);
}
local.close();
}
示例4: fileSize
import it.sauronsoftware.ftp4j.FTPException; //导入依赖的package包/类
/**
* Gibt die Größe der angegebenen Datei zurück.
*/
private static long fileSize (String remote, FtpConnection con)
throws IOException, FTPIllegalReplyException, FTPException
{
boolean conWasNull = con == null;
if (conWasNull)
con = cons.getClient();
FTPClient client = con.getFtpClient();
long retval;
try
{
retval = client.fileSize(remote);
}
finally
{
if (conWasNull)
con.setBusy(false);
}
return retval;
}
示例5: startQualifyGame
import it.sauronsoftware.ftp4j.FTPException; //导入依赖的package包/类
/**
* Startet ein Qualifikations-Spiel des angegebenen Typs mit der
* angegegebenen KI.
*/
public static GameImpl startQualifyGame (int gameId, int requestId, String language, String ai, String qualilang)
throws IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException,
ReflectiveOperationException, FTPListParseException
{
LoadedGameLogic logic = loadGameLogic(gameId);
UUID uuid = randomUuid();
// die KIs herausfinden. QualiKI: -gameId version 1
int numAis = logic.getGameLogic().playerAmt();
String ais[] = new String[numAis];
ais[0] = ai;
for (int i = 1; i < numAis; i++)
ais[1] = "-" + gameId + "v1";
String[] languages = { language, qualilang };
// Spiel starten
GameImpl game = new GameImpl(gameId, logic.getGameLogic(), uuid, requestId, false, languages, ais);
game.setGameFinishedListener(logic);
synchronized (lock)
{
games.put(uuid, game);
}
return game;
}
示例6: updateGroup
import it.sauronsoftware.ftp4j.FTPException; //导入依赖的package包/类
private SyncGroup updateGroup(SyncGroup group, FtpClient client) {
try {
return retryableUpdateGroup(group, client);
} catch (IllegalStateException | FTPException | IOException | FTPIllegalReplyException e) {
log.warn("Could not update {} due to {}", group.getRemoteDir(), e.toString());
return null;
}
}
示例7: connect
import it.sauronsoftware.ftp4j.FTPException; //导入依赖的package包/类
private boolean connect(FtpClient client, Map<String, String> credentials) {
try {
retryableConnect(client, credentials);
return true;
} catch (FTPException | IOException | FTPIllegalReplyException e) {
log.warn("Could not connect to FTP server after retrying: {}", e.toString());
return false;
}
}
示例8: deleteFiles
import it.sauronsoftware.ftp4j.FTPException; //导入依赖的package包/类
/**
* Delete a list of files and directories.
* @param server The FTP server.
* @param elements The specified list.
*/
public void deleteFiles(FtpServer server, List<FileEntity> elements) throws FTPException, IOException, FTPIllegalReplyException {
FTPClient client = this.getConnection(server);
for (FileEntity element: elements) {
if(element.isDirectory()) {
client.deleteDirectory(element.getPath());
}
else {
client.deleteFile(element.getPath());
}
}
}
示例9: cacheLibrary
import it.sauronsoftware.ftp4j.FTPException; //导入依赖的package包/类
private void cacheLibrary (String language, String name)
throws IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException,
FTPListParseException
{
File libdir = new File(cachedir, language + "/" + name);
WorkerMain.getLogger().info("Caching Library " + name + " (" + language + ") to " + libdir.getAbsolutePath());
libdir.mkdirs();
DatastoreFtpClient.retrieveLibrary(name, language, libdir);
File libtar = new File(cachedir, language + "/" + name + ".tar.bz2");
TarArchiveOutputStream tar = new TarArchiveOutputStream(new BZip2CompressorOutputStream(new FileOutputStream(libtar)));
tar.setBigNumberMode(BIGNUMBER_POSIX);
tar.setLongFileMode(LONGFILE_POSIX);
addToTar(libdir, tar, "");
tar.close();
}
示例10: getLibDir
import it.sauronsoftware.ftp4j.FTPException; //导入依赖的package包/类
public File getLibDir (String language, String name)
throws IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException,
FTPListParseException
{
File libdir = new File(cachedir, language + "/" + name);
if (!libdir.exists())
cacheLibrary(language, name);
return libdir;
}
示例11: getLibTarBz2
import it.sauronsoftware.ftp4j.FTPException; //导入依赖的package包/类
public File getLibTarBz2 (String language, String name)
throws IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException,
FTPListParseException
{
File libtar = new File(cachedir, language + "/" + name + ".tar.bz2");
if (!libtar.exists())
cacheLibrary(language, name);
return libtar;
}
示例12: getLib
import it.sauronsoftware.ftp4j.FTPException; //导入依赖的package包/类
@Override
public File[] getLib (String language, String name)
{
try
{
return getLibDir(language, name).listFiles();
}
catch (IOException | FTPIllegalReplyException | FTPException | FTPDataTransferException | FTPAbortedException
| FTPListParseException e)
{
throw new RuntimeException(e);
}
}
示例13: getClient
import it.sauronsoftware.ftp4j.FTPException; //导入依赖的package包/类
public FtpConnection getClient () throws IOException, FTPIllegalReplyException, FTPException
{
while (true)
{
synchronized (lock)
{
for (int i = 0; i < cons.length; i++)
{
if (cons[i] == null)
{
new Logger().debug("Erstelle einen neuen Clienten zum FTP-Server");
FTPClient c = new FTPClient();
c = DatastoreFtpClient.connect(c);
cons[i] = new FtpConnection(c);
cons[i].setBusy(true);
return cons[i];
}
if (!cons[i].isBusy())
{
cons[i].setBusy(true);
cons[i].setFtpClient(DatastoreFtpClient.connect(cons[i].getFtpClient()));
return cons[i];
}
}
try
{
lock.wait();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
}
示例14: retrieveDir
import it.sauronsoftware.ftp4j.FTPException; //导入依赖的package包/类
/**
* Speichert alles im Remote-Directory im local-Verzeichnis.
*/
public static void retrieveDir (String remote, File local, FtpConnection con)
throws IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException,
FTPListParseException
{
boolean conWasNull = con == null;
if (conWasNull)
con = cons.getClient();
FTPClient client = con.getFtpClient();
try
{
String cwd = client.currentDirectory();
client.changeDirectory(remote);
local.mkdirs();
for (FTPFile f : client.list())
{
if (f.getType() == FTPFile.TYPE_FILE)
retrieveFile(f.getName(), new File(local, f.getName()), con);
else if (f.getType() == FTPFile.TYPE_DIRECTORY)
retrieveDir(f.getName(), new File(local, f.getName()), con);
}
client.changeDirectory(cwd);
}
finally
{
if (conWasNull)
con.setBusy(false);
}
}
示例15: retrieveAi
import it.sauronsoftware.ftp4j.FTPException; //导入依赖的package包/类
/**
* Speichert das tar-bzip2-Archiv mit den compilierten Daten der KI im
* OutputStream local.
*/
public static void retrieveAi (int id, int version, OutputStream local)
throws IllegalStateException, IOException, FTPIllegalReplyException, FTPException,
FTPDataTransferException, FTPAbortedException
{
retrieveFile(aiBinPath(id) + "/v" + version + ".tar.bz2", local, null);
}