// Need this import for reading data:
import java.io.*;

// reading data in a do/while loop until a specific command
public class DoWhileInput {

    public static void main (String [] args) throws IOException {
	// Create a buffered reader
	BufferedReader in = new BufferedReader(
			new InputStreamReader(System.in));
	// string for storing a line of input
	String line = new String();

	do {
	    System.out.print("Please say something. Say \"bye\" to end. ");
	    line = in.readLine();
	    System.out.println("You said: " + line);
	} while (! line.equalsIgnoreCase("bye"));

	System.out.println("Nice talking with you! See you later...");
    }

}

This is an example from CSci 1211 course.