Hi,

On Sep 21, 4:39 pm, Ishtiaq Ahmed <[email protected]> wrote:
> Dear all,
> I have a  problem with input techniques from user. Suppose user can feed up 
> program 3 lines as:
> Department of Computer science
> and
>
> engineering University of Dhaka
>
> [The third line is empty string]
> But I don't know how many lines of strings are there and we have
> to process single line and then to next line. After reading all the lines
> i have to output all inputs accordingly. Output should be same as input.
> Here is my program
> import java.util.ArrayList;
> import java.util.Iterator;
> import java.util.Scanner;
>
> public class InputTechnique {
>     public static void main(String args[]){
>          Scanner scan = new Scanner(System.in);
>          ArrayList<String> aList = new ArrayList<String>();
>          while(scan.hasNextLine()){
>              aList.add(scan.nextLine());
>          }
>          Iterator it = aList.iterator();
>          while(it.hasNext())
>              System.out.println(it.next());
>     }}
>
> it cannot break the first while loop and continue taking inputs from user. I 
> want to know how does i take inputs till the end of user inputs.
>
You have to define something, which marks the end of the Input for
you. On my
OpenSolaris Box, when I start your programm, a <ctrl>-<d> finishes the
Input and
replays the input. The <ctrl>-<d> marks the end-of-data.

HTH
Ewald


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to