blob: dab841f3d7f2f9cf29b989de82cac98931075a6c [file] [log] [blame]
chrismair00dc7bd2014-05-11 21:21:28 +00001/*
2 * Copyright 2007 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.mockftpserver.stub.example;
17
18import org.apache.commons.net.ftp.FTPClient;
19
20import java.io.IOException;
21import java.net.SocketException;
22
23/**
24 * Simple FTP client code example.
25 *
26 * @version $Revision$ - $Date$
27 *
28 * @author Chris Mair
29 */
30public class FtpWorkingDirectory {
31
32 private String server;
33 private int port;
34
35 /**
36 * Return the current working directory for the FTP account on the server
37 * @return the current working directory
38 * @throws SocketException
39 * @throws IOException
40 */
41 public String getWorkingDirectory() throws SocketException, IOException {
42 FTPClient ftpClient = new FTPClient();
43 ftpClient.connect(server, port);
44 return ftpClient.printWorkingDirectory();
45 }
46
47 /**
48 * Set the hostname of the FTP server
49 * @param server - the hostname of the FTP server
50 */
51 public void setServer(String server) {
52 this.server = server;
53 }
54
55 /**
56 * Set the port number for the FTP server
57 * @param port - the port number
58 */
59 public void setPort(int port) {
60 this.port = port;
61 }
62
63}