john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

Iofun

import java.lang.*;
import java.io.*;


public class  Iofun
{
    public static void main(String[] args) throws IOException
    {

        InputStreamReader input = new InputStreamReader(System.in);
        BufferedReader get = new BufferedReader (new InputStreamReader(System.in));

        String Echo;
        int aByte;
        boolean test = false;

    String tempstring = null;

    for(int j = 0; j<4; j++)
        {
            tempstring = (tempstring + ", " );

        }
        System.out.println(tempstring);
        get.readLine();
        System.exit(1);


//int aChar;
//                  while ((aByte = input.read()) >= 0)
//                  {System.out.print(aByte);       }

        while(true)
        {
            do{
                if(input.ready())
                {
                    break;
                }
                else
                {
                    MyTimer.timeFor(250);//a quarter second wait
                }
            }while(true);

            Echo = get.readLine();
            if(Echo.equals(""))
            {
                System.out.print("-");
                Echo = "Username: " + get.readLine();
                System.out.println(Echo);

                if(Echo.equals("Username: quit"))
                {       System.exit(1);     }

            }

        }//while close brace


//      InputStream syn = System.in;
//      InputStreamReader cin = new InputStreamReader(System.in);
//      BufferedReader Uinput = BufferedReader cin;


//      cin = (System.in).getInputStream();


/*      boolean test = false;
        int aChar;
        int counter=0;
        int temp;

        while( (counter = syn.available()) == 0)
        {

        }
        System.out.println("I told ou so");

        while(counter > 0)
        {
            temp = syn.read();
            System.out.println(temp);
            if(counter == 0)
            {break;
            }
        }
        System.out.println("there");
        System.exit(1);

        while(true)
        {
            test = cin.ready();

            if(test == true)
            {
                aChar = cin.read();
                System.out.println(aChar);
                    break;
            }
        }




        System.out.println("    fin");


        while(true  )
        {



            if(Echo.equals("quit"))
                break;

            System.out.println("Echo: " + Echo);
            Echo = cin.readreadLine();
        }




/*            while(cin.ready())
            {
                UserInput = new BufferedReader(cin);
                UserString = UserInput.readLine();
                System.out.println(UserString);
                if(UserString == "z")
                    {   break;  }

            }//while

    */
    }//main method

}//class end

class MyTimer
{

//pauses for the "duration" in milliseconds
    public static void timeFor(int duration)
    {
        long timer;
        long starttime;

            starttime = System.currentTimeMillis();
            do{
                timer = System.currentTimeMillis();
            }while( (timer - starttime) < duration);
    }
}

  • « Manager
  • 4 22Client »

Published

Apr 22, 2001

Category

java-chat-university-v2

~177 words

Tags

  • io 1
  • java 252