Home » Archive

Articles tagged with: Read Input From User

Java Codes »

[13 Feb 2009 | One Comment | 1,500 views]

This code example takes input from user and write the contents of the input to a file for every time the user hits the enter key.
This is continued until the user types the word ‘finished’, then the program exists. A StringBuilder is used to check whether the word ‘finished’ has been typed in.

package com.javadb.examples;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;