Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How to make this print only the first 200 results?

  1. #1
    Member
    Join Date
    Aug 2010
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to make this print only the first 200 results?

    This piece of code prints everything that it finds. I want to print only the first 200 results. Here is the code
    for (String key : data.keySet()) {				
    					Set<File> files = data.get(key);
    					for (File file : files) {
    						out.println("<TR valign=top>");
    						out.println("<TD align=left><div class=\"wpmd\">");
    						out.println("<div><font color=\"#000000\">"+pathValue+(file.getPath().replace('\\', '/'))+ "</font></div>");	
    						out.println("</TD>");
    						out.println("</TR>");				
    					}
    				}

    The type of data is:
    public class Data extends HashMap<String, Set<File>> {
    }
    Data data=.....


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,338
    Thanks
    56
    Thanked 2,376 Times in 2,346 Posts

    Default Re: How to make this print only the first 200 results?

    Use a counter in the output generating loop. When the counter reaches the desired value, exit the loops.
    See the break statement.

  3. #3
    Member
    Join Date
    Aug 2010
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to make this print only the first 200 results?

    Quote Originally Posted by Norm View Post
    Use a counter in the output generating loop. When the counter reaches the desired value, exit the loops.
    See the break statement.
    Thank you, it worked!

Similar Threads

  1. How can i view search results by using servlet and jsp?
    By noFear in forum Java Theory & Questions
    Replies: 3
    Last Post: August 27th, 2010, 12:22 PM
  2. Showing database results
    By randyrr in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 28th, 2010, 12:26 AM
  3. Searching and printing string results from an Arraylist. Having difficulty.
    By Espressoul in forum Loops & Control Statements
    Replies: 1
    Last Post: February 25th, 2010, 08:32 PM
  4. How to print results to screen
    By NinjaLink in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 19th, 2010, 01:46 PM
  5. Football Results
    By RSYR in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 4th, 2009, 07:24 PM