1/*
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 java.io.IOException;
19import java.net.SocketException;
20
21import org.apache.commons.net.ftp.FTPClient;
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
34    /**
35     * Return the current working directory for the FTP account on the server
36     * @return the current working directory
37     * @throws SocketException
38     * @throws IOException
39     */
40    public String getWorkingDirectory() throws SocketException, IOException {
41        FTPClient ftpClient = new FTPClient();
42        ftpClient.connect(server);
43        return ftpClient.printWorkingDirectory();
44    }
45
46    /**
47     * Set the hostname of the FTP server
48     * @param server - the hostname of the FTP server
49     */
50    public void setServer(String server) {
51        this.server = server;
52    }
53
54}
55