Auf Thema antworten

Hallo,


bin neu hier und obwohl seit eben angemeldet bin, habe ich die letzten monaten hier einiges gelesen:D...


ich hab ein kleines Problem mit eine übung für die FH.


[code=Java]import java.net.*;

import java.io.*;

import java.util.*;


class Client

{

  private static Scanner in;


public static void main( String[] args )

  {

    Socket client = null;


    try

    {

    // Client mit Port 3141 wird erzeugt

      client = new Socket( "localhost", 3141 );

      System.out.println("Client gestartet");

     

    in = new Scanner( client.getInputStream() );

    PrintWriter out = new PrintWriter( client.getOutputStream(), true );

     

      StringReader wortein = new StringReader();

      String suchwort = wortein.stringread();


      out.println(suchwort);// wird an server gesendet

      String inputLine = "";

      while ((inputLine = in.nextLine()) != null)

      {

          System.out.println(inputLine);

      }

        /*  while ((inputLine = in.nextLine()) != null)

          {

            System.out.println(inputLine);

          }*/

    

    }

    catch ( UnknownHostException e ) {

      e.printStackTrace();

    }

    catch ( IOException e ) {

      e.printStackTrace();

    }

   

    finally {

      if ( client != null )

        try {

            client.close();

            }     

      catch ( IOException e ) {

         

      }

     

    }

  }

}[/code]



Fehler

[CODE]

Exception in thread "main" java.util.NoSuchElementException: No line found

    at java.util.Scanner.nextLine(Unknown Source)

    at Client.main(Client.java:27)

[/CODE]


Wenn die anderen Klassen auch erforderlich sind kann ich die natürlich hochladen..



Danke



Oben