Sending large Strings ?! only sending a line
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Sending large Strings ?! only sending a line

  1. #1
    Join Date
    Apr 2011
    Posts
    3

    Sending large Strings ?! only sending a line

    Hello,

    So I have this client and server where the server is sending a largeeeee string over the network to a client. But sadly its only sending one line... I don't quite understand the problems cause. I suspect its something to do with how big the container is on the clients side but that's just speculation.

    any idea whats causing this? and how to resolve?

    Here is my code :

    ------------------------------------------CLIENT------------------------------------------
    Socket server ;
    BufferedReader in;
    PrintWriter out;

    server = new Socket("localhost",7777);

    // BufferedReader
    in = new BufferedReader
    (new InputStreamReader(server.getInputStream()));

    // PrintWriter
    out = new PrintWriter
    (server.getOutputStream(), true /* autoFlush */);

    String bookpage = in.readLine();// reads data from server
    System.out.println(bookpage);

    ------------------------------------------SERVER------------------------------------------

    BufferedReader in;
    PrintWriter out;
    // establish server socket
    ServerSocket s = new ServerSocket(7777);

    // wait for client connection
    Socket incoming = s.accept( );

    in = new BufferedReader
    (new InputStreamReader(incoming.getInputStream()));

    out = new PrintWriter
    (incoming.getOutputStream(), true /* autoFlush */);


    String Apage = "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA" ;


    out.println(Apage);//Sends page

  2. #2
    Join Date
    May 2009
    Location
    Surrey, UK
    Posts
    285

    Re: Sending large Strings ?! only sending a line

    When posting code use code tags.

    Your code is incomplete so I may be wrong, but it seems your client is reading only one line.

  3. #3
    Join Date
    May 2006
    Location
    UK
    Posts
    4,474

    Re: Sending large Strings ?! only sending a line

    Please use code tags when posting code.

    You're only reading in one line. If you want to read in all lines sent you need to have a loop around the code where you read in a line. Your code should keep on reading lines until readLine() returns null.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  4. #4
    Join Date
    Apr 2011
    Posts
    3

    Re: Sending large Strings ?! only sending a line

    Hey,

    Sorry about not using tags, I am extremely new to programming and talking on forums about it ! How do you use tags?

    keang I get what your saying but I am not sure how do to that code. should I create some kind of dynamic array to put the strings into ? could you write me a example of what you mean please so I may study it!


    on my rough attempt I tried to come up with a loop on the clients side where the server tells it how many lines its going to get.... I doubt it will work but its a attempt... also it raises a new question of how to count the number of lines on the server side

    so like :
    //CLIENTSIDE
    Code:
    int lengthofdatarecivedint;
    int lengthofdatarecivedstring;
    
    
     
    lengthofdatarecivedstring =  in.readLine();
    lengthofdatarecivedint = Integer.parseInt(lengthofdatarecivedstring);
    
    String bookpage[lengthofdatarecivedint] 
    
    int counter = 0;
    
    do {
     bookpage[lengthofdatarecivedint]  = in.readLine();// reads data from server
    
    }while(counter <= lengthofdatarecivedint )
    //SERVER SIDE
    Code:
    BufferedReader in;
    PrintWriter out;
    // establish server socket
    ServerSocket s = new ServerSocket(7777);
    
    // wait for client connection
    Socket incoming = s.accept( );
    
    in = new BufferedReader
    (new InputStreamReader(incoming.getInputStream()));
    
    out = new PrintWriter
    (incoming.getOutputStream(), true /* autoFlush */);
    
    
    String Apage = "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA"+"\n"+
    "BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA" ;
    
    String length = ??????????????? how to get???
    out.println(length);
    out.println(Apage);//Sends page

  5. #5
    Join Date
    May 2006
    Location
    UK
    Posts
    4,474

    Re: Sending large Strings ?! only sending a line

    How do you use tags?
    At the bottom of each of my posts it explains how to use code tags. Although I see you have used them in your latest post.

    You basically have 2 choices:

    1. Read in one line at a time and perform whatever operation you need to do before reading the next line.
    2. Read in each line and store it in something like an ArrayList. Then once you have all the lines, perform whatever operations you need to do.

    If you read the API docs for readLine() it tells you it will return the next line in the stream or null if the end of the stream has been reached. So you need to repeatedly read in a line until you get a null return value. Assuming you need to store the lines you could do something like this:
    Code:
    List<String> myList = new ArrayList<String>();
    
    String myLine = in.readLine();
    while ( myLine != null ) {
        myList.add(myLine);
        myLine = in.readLine();
    }
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  6. #6
    Join Date
    Apr 2011
    Posts
    3

    Re: Sending large Strings ?! only sending a line

    aahh yes, I looked up how to do tags, but wasnt sure 100% if it would work so I wanted to cover myself

    I probably wont be storing it as I just want to throw it to screen. Which the code is easy to do, I have it hooked up to a gui and I am just appending the text.

    hmmm I tried that code and got a error, whats that about?

    Code:
    Exception in thread "main" java.net.SocketException: Connection reset
            at java.net.SocketInputStream.read(SocketInputStream.java:168)
            at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
            at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
            at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
            at java.io.InputStreamReader.read(InputStreamReader.java:167)
            at java.io.BufferedReader.fill(BufferedReader.java:136)
            at java.io.BufferedReader.readLine(BufferedReader.java:299)
            at java.io.BufferedReader.readLine(BufferedReader.java:362)
            at clientpagetest.Main.main(Main.java:74)
    Java Result: 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center