hi..i'm new in java programing ..
sorry but i don't know where i should write my question..
i have this program "FTP client " with 2 errors .."illegal start of expression "
and "134 error "class ,interface ,or enum expected "
i checked "{} ()"...can you help me plz?

import java.io.*;
import java.net.*;
import java.util.*;
 public class ClientFTP {

	public boolean connect(String host, int port, String userName, String passWord) throws UnknownHostException,IOException {
		connectionSocket = new Socket(host, port);
		outputStream = new PrintStream(connectionSocket.getOutputStream());
		inputStream = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
		if (!isPositiveCompleteResponse(getServerReply())) {
			return false;
		return true;
	 // Disconnects from the host to which we are currently connected.
	public void disconnect() {
		if (outputStream != null) {
			try {
				if (loggedIn) {
				}//end if 
			} // end try

			catch (IOException e) {
			}//end catch
			outputStream = null;
			inputStream = null;
			connectionSocket = null;
		}//end if
	}//end function
	 // 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);
		loggedIn = isPositiveCompleteResponse(response);
		return loggedIn;
		//if (  isPositiveCompleteResponse(response))
		//return true;
	 // Logout before you disconnect (this is good form).
	public boolean logout() throws IOException {
		int response = executeCommand("quit");
		loggedIn = !isPositiveCompleteResponse(response);
		return !loggedIn;
	//  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);
 //----------------------------------------Here is the code to test the client program

public static void main(String[] args) throws IOException {
		String serverName;
		String portNumber;
		int port = 21;
		FTPConnection ftp = null;
			if (args.length == 0) {
				//System.out.print("Enter the server you would like to connect to: ");
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	          	//serverName= br.readLine();
				serverName=getStringFromUser("Enter the server you would like to connect to: ");
				if (serverName.length() == 0) {
				}//end if
			} //end if

			else {
			serverName = args[0];
			}//end else

			String userName = "";
			String passWord = "";
			// set the FTPConnection parameter to true if you want to
			// see debug output in your console window
			ftp = new FTPConnection(true);
			System.out.println("Attempting to connect to " + serverName);
			ftp.connect(serverName, port, userName, passWord);
			if(ftp.login("", "")){ 
				System.out.println("Successfully logged in!");
				System.out.println("System type is: " + ftp.getSystemType());
				System.out.println("Current directory is: "+ ftp.getCurrentDirectory());
				String files = ftp.listFiles();
			}// end if

		// private function that gets console input from the user
	       private static String getStringFromUser(String prompt) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		return br.readLine();
	}//end func

}//end class

You have an extra } at the bottom of the source file and you need to instead place this } before the private method getStringFromUser.

This article has been dead for over six months. Start a new discussion instead.