Help with printing from an array

hello there, looking for help. Basically i have read a text file into an array. I can print a sentence from the array using startsWith()...if i take that code out, and just put in the last part:
while(!(words.trim()).startsWith("slightly")) {
     System.out.println(i + ":" + words[i] + ":");
     i++;
this basically prints out the whole text file until it reaches the word slightly. I want to print out text that is in between two words. Now i can stop printing with this , any suggestions on how i can tell it to start printing when it finds a word....
public static void main( String[] args )
     int i = 0;
// will store the words read from the file
List<String> wordList = new ArrayList<String>();
BufferedReader br = null;
try
// attempt to open the words file
br = new BufferedReader( new FileReader( "ireland.txt" ) );
String word;
while( ( word = br.readLine() ) != null )
// add the read word to the wordList
wordList.add( word );
} catch( IOException e ) {
e.printStackTrace();
} finally {
try {
// attempt the close the file
br.close();
catch( IOException ex ) {
ex.printStackTrace();
String[] words = new String[ wordList.size() ];
// wordList to our string array words
wordList.toArray( words );
System.out.println(" Returning line ");
// loop and display each word from the words array
/*while(i < words.length )
     String tempWord = words[i].trim();
     //area
     if (tempWord.startsWith("'''Loc"))
          System.out.println(i+":"+ words[i]+":" );     
     i++;
/*while(!(words[i].trim()).startsWith("slightly")) {
     System.out.println(i + ":" + words[i] + ":");
     i++;

This may help, it looks like the same assignment:
http://forum.java.sun.com/thread.jspa?threadID=5144211
Yeah, and it's from the same guy.
Thanks (NOT) for posting yet another thread about the
same problem, tras.D'OH! I didn't even notice that. In what ways were the answers you got in the other thread insufficient?

Similar Messages

  • Please help with printing from Thinkpad

    I've spent the last couple of days reviewing similar posts, and tried suggestions within with no success. Here's my problem:
    I have an older iMac running 10.3.9 wirelessly connected to the internet with an Airport Extreme I picked up about a year ago. Recently I decided to run my printer through the Airport. My Mac found the printer with no problem, and prints just fine.
    I also have an IBM ThinkPad, running Windows XP. I have no trouble, after initial setup headaches, getting the ThinkPad to find the network and get online, but I can't print from the ThinkPad.
    I used Bonjour to find the printer, an hp deskjet 940c, and the setup seemed to work. (I used the manufacturer's disk for the driver.) But everytime I try to print I get: "this document failed to print" error message. The ThinkPad is connected to the network and online.
    I also wish the ThinkPad could find the iMac. Is this wishful thinking?
    Any help would be greatly appreciated.

    Dear snaggl2th,
    Try this
    pageFormat = pf
    g = g2
    g.translate((int)pageFormat.getImageableX(),(int)pageFormat.getImageableY());
    int wPage = (int)pageFormat.getImageableWidth();
    int hPage = (int)pageFormat.getImageableHeight();
    g.setClip(0,0,wPage,hPage);Hope it helps
    Joey

  • Please help with geometric objects in ARRAY...........

    I am facing a programming issue here;
    I am supposed to create an array of circle objects of random dimensions.
    Next, I am supposed to check each circle and make sure it does not intersect with any other circle in the array. If it does, I am expected to remove the circles that intersect with it from the array. I have found this technique more feasible, but in the question, it is suggested to check for intersection before the circle is added to the array. To quote "Check that the new circle does not intersect a previous one. You will need to iterate through the array list and verify that the current circle does not intersect with a circle in the array list. Add the circle to the array list if it does not intersect with another one." For some reason, I think my approach is more feasible. But feel free to differ.
    Then, I am supposed to draw the circles.
    The program compiles but when it is run, only one circle is drawn.
    Any advice would be appreciated, and as before thank you in advance.
    import java.util.Random;
    import java.awt.geom.Ellipse2D;
    import javax.swing.JComponent;
    import java.util.ArrayList;
    import java.awt.Graphics2D;
    import java.awt.Graphics;
    public class CirclesComponent extends JComponent
    public CirclesComponent(int numberCircles)
          NCIRCLES = numberCircles;
          circles = new ArrayList<Ellipse2D.Double>();
          final int XRANGE = 292;
          final int YRANGE = 392;
          final int RRANGE = 20;
             generator = new Random();
             double x = generator.nextInt(XRANGE) + 1;
             double y = generator.nextInt(YRANGE) + 1;
             double r = generator.nextInt(RRANGE) + 1;
             double w = 2 * r;
             double h = 2 * r;
             for (int i = 1; i <= NCIRCLES; i++)
             Ellipse2D anEllipse = new Ellipse2D.Double(x, y, w, h);
             circles.add(anEllipse);
          Test if two circles intersect.
          (distance between centers is less than sum of radii)
    public void circlesIntersect()
              Ellipse2D zeroEllipse = (Ellipse2D)circles.get(0);
               for (int v = 1; v <= circles.size(); v++)
                   Ellipse2D anotherEllipse = (Ellipse2D)circles.get(v);
                         double radius1 = zeroEllipse.getWidth() / 2;
                         double radius2 = anotherEllipse.getWidth() / 2;
                         double dx = zeroEllipse.getX() + radius1 - anotherEllipse.getX() - radius2;
                         double dy = zeroEllipse.getY() + radius1 - anotherEllipse.getY() - radius2;
                         double distance = Math.sqrt(dx * dx + dy * dy);
                         if (distance < radius1 + radius2)
                         circles.remove(v);
       public void paintComponent(Graphics g)
          Graphics2D g2 = (Graphics2D) g;
          for (int z = 0; z < circles.size(); z++) // iterate through every circle in the list
          g2.draw((Ellipse2D)circles.get(z)); // draw the circle
       public void getRejection()
           System.out.println("The percentage of rejected circles is " + ((circles.size() / NCIRCLES ) * 100));
           System.out.println("The size of the array is " + (circles.size()));
       private int NCIRCLES; 
       private ArrayList circles;
       private Random generator;
    import java.util.Scanner;
    import java.awt.Graphics2D;
    import java.awt.Graphics;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    public class CirclesTester
    public static void main(String[] args)
          Scanner thescanner = new Scanner(System.in);
          System.out.print("How many circles do you want? ");
          int totalCircles = thescanner.nextInt();
          CirclesComponent theCircle = new CirclesComponent(totalCircles);
          theCircle.getRejection();
          JFrame frame = new JFrame();
          frame.setSize(300, 400);
          frame.setTitle("Non-Intersecting Circles");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.add(theCircle);
          frame.setVisible(true);
    }

    homebrewed wrote:
    I am supposed to create an array of circle objects of random dimensions.
    Next, I am supposed to check each circle and make sure it does not intersect with any other circle in the array. If it does, I am expected to remove the circles that intersect with it from the array. I have found this technique more feasible, but in the question, it is suggested to check for intersection before the circle is added to the array. To quote "Check that the new circle does not intersect a previous one. You will need to iterate through the array list and verify that the current circle does not intersect with a circle in the array list. Add the circle to the array list if it does not intersect with another one." For some reason, I think my approach is more feasible. But feel free to differ.Gladly. It is much simpler to iterate over a List and check if the new circle is valid than to iterate over a List and remove those circles that make the new circle invalid. Note that the code you have now will skip items in the list when a circle is removed.
    Then, I am supposed to draw the circles.
    The program compiles but when it is run, only one circle is drawn. And why is that? Is it only drawing one of the circles? Is it drawing all the circles but they're all the same circle? Does your list only contain one circle?
    You need to run your program in a debugger or add println() statements to output your program state at important points along the execution path.
    Once you figure out why you're only getting one circle, it becomes much simpler to figure out how it happened.

  • Help with Print Layout Designer

    Hi all,
    I'm not sure if I should post this here or not, I already posted it in the Business One Forum.  Moderator(s)  if this is not the proper place please delete it and let me know that it is not the appropriate venue.
    I need some help with Print Layout Designer.  I am running 2005A SP01, and my customer wants a modification to the Sales Backorder Report.  They want to add the column "In Stock" to both the report as displayed on the screen and the printed document.  The report rendered to the screen has the In Stock, but it is not checked as visible.  I check it and In Stock shows up as designed.  The part I am having problems with is the printed document. I opened the PLD from the Backorder Report, and saved it under a different name.  I resized some of the columns in the repetitive area (header and data) to make room for the In Stock column.  I CAN add the text field Instock as free text and enter "In Stock" as the content.  I looked at the "backorder" column in the PLD, and it is a text field with the source System Variable and the variable is 109.  I would assume that all I need to do in my added column is to set the source to System Variable and enter the variable number.  That is the problem; I can't find the variable number for that column.  I looked on the report rendered to the screen with system information on and the variable is "3 #000027825,OnHand".  I looked at the Back Order column of the report rendered to the screen and the variable is "3 #000028725,OpenCreQty".  I found a spreadsheet that is supposed to contain a list of system variables for 2007A, but the document type for this report is BRDR and that document type does not appear in the list of document types in that spreadsheet.  I looked for a similar spreadsheet for 2005A SP01 but didn't find one.  I DID find a document "How To Customize Printing Templates with the Print Layout Designer".  According to that document, I should be able to get the system variable from the report rendered to the screen with System Information turned on.  Can anyone help?
    TIA,
    Steve

    I haven't dealt with this before so I can't be certain, but here are my thoughts.
    The Backordered Qty is probably a calculated field, so that's why it's a system variable. The In Stock is a defined field, so you probably can use the file and field number, OITM, OnHand. I would look at maybe the stock number or description to see how those are setup on the form instead of the backordered qty field.

  • I need help with printing labels.  please

    I need help with printing labels.  thanks in advance

    Welcome to Apple Support Communities.
    In Address Book, first select a name or group of names to print.
    Then File, Print, select Style, Mailing Labels, then Layout to select a specific target label (such as an Avery number), or define your own...

  • Please i need help with switch from the us store to malaysian store how i can switch

    Please i need help with switch from the us store to malaysian store how i can switch

    Click here and follow the instructions to change the iTunes Store country.
    (82303)

  • Help with printing hard copy from Acrobat PDF

    Copy created in InDesign and printed to Adobe PDF is OK on screen but printing hard copy with random chunks of text missing. Same on both my printers, doesn't happen with doPDF. Any ideas? Thanks

    I suspect that what you are asking is simply to print to a new PDF with print as image selected. You can also save as an image file and then open the images as a new PDF.

  • HP Officejet 6800 e-All-in-One-series - issues with printing from MSWord / Setup

    I have been trying to set up the HP Officejet it seems for over 2 weeks - it works then doesn't - I dont want to return it but if it doesnt work proper .... I removed and reinstalled software - yesterday printed from MSWORD - today its not --- it will print pages off the internet but not from my MSWORD - its set up wirelessly - so frustrated - and what's worse is I am HP lover and now I cant even find a HP support phone number to call and I am pretty sure I remember being told while I was making my purchasing decision I could call HP for support with reference to set up when I bought the printer. Can someone tell me if the printer then not working is normal for this printer - with reference to printing MSWORD etc and if not is there some special place I am suppose to click to fix - thank you in advance 

    Hi @TheoD,
    Welcome to the HP Forums!
    Sorry to hear about your frustration with not being able to print from MS Word with your HP Officejet 6800 printer. But I am happy to help!
    It is definitely odd that this printer is not printing from MS Word but will from the Internet. I am not seeing much documentation for an HP Officejet 6800, is it possible that you have the HP Officejet 8600? Just double-checking to make sure I provide the correct information. To find your printer's Product/Model Number follow instructions in this link. Finding Your HP Product Model Number.
    For further assistance, I will also need to know what Operating System you are using. Windows or Mac? What version? If you do not know the Operating System you are using, please visit this website. Whatsmyos.
    If you are using Windows, please try our HP Print and Scan Doctor, and let me know what happens!
    Otherwise, if you still prefer to call someone, please call our phone support at 800-474-6836. If you live outside the US/Canada Region, please click the link below to get the support number for your region. Country-language selector.
    Have a nice day!
    RnRMusicMan
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" to say “Thanks” for helping!

  • Problem with printing from Acrobat Reader XI

    SInce I installed Acrobat Reader XI I have got problems with printing out pages. The text starts a bit down (2 cm) on the paper, resulting that the last part of the text on the page will be missing. And the missing part does not follow on page 2, it just don´t comes out!
    It doesn´t matter what settings i click in on the print setting page in Acrobat Reader, it always gets the same result.
    Does anyone know what can be the problem?

    No files appeared in C:\Users\Pavilion\AppData\Roaming\Adobe\Adobe PDF\Settings but they did appear in Distiller.
    I tried to copied them from C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\Settings, but found they were already there.  I copied them by adding -COPY before .joboptions in the name.  Now they appeared in  Printing Preferences with the -COPY added.
    I tested a print from Word (using File / Print), but was not prompted for the filename or location.  I checked my entire system and couldn't find the PDF file anywhere.  I tried changing the Port to Desktop\*.pdf using Printer Properties, but that didn't work either.
    I was able to successfully use the Acrobat menu item in Word & Excel to create a PDF but it automatically created the file on the Desktop without an option to change the filename.
    After several days and hours, I gave up and installed Acrobat X on the W7 computer.  I can still use Acrobat XI on the W8 computer.  So be it!
    Thanks anyway for your attempts to help.

  • Can someone help with print problem?

    I have problem saving the printer driver settings in CS6, and not shure it is problem with my installation only. Can anyone check for simlar behaviour by selecting some printer driver settings that are not the default ones and see if those are saved when Done button in the Print dialog is pressed. Thank you!

    There are only few threads describing the similar problem, I have been checking for meny years for that because it is nothing new to me I remember the same behaviour in CS and CS2, and allways wondered why there was no official fix for it. Actually, the reason to ask for help is not the bug itself, but rather the bizzare lack of user complaints in community forums, that would have eventually rised the program designers attention. Am I the only one out of maybe millions of Illustrator userrs that regularly prints from it?

  • Help in printing from flex application

    Hi Guys,
    I am working from last few days with the printing via flex application, i face some issues while printing if any have suggestion or help it would be great..
    1. Print which i got is not clear, like fonts are little fuzz or blur like.
    2. Is printing via flex application is like the same as we print from MS WORD ?.
    3. Choosing Flex for printing purpose like labels or A4 paper is right choice or not ?
    Please comment!!
    Thanks in advance,
    Himanshu

    I went first to the Apple Store and tried an App and did not work had to inter the IP which I know  is correct. What I was looking for is someone that is using the 7210 with the Iphone and what App they are using. I may have something else going on.
    Thank you for the response.
    Dee

  • Need help with Printer Setup conventions

    I can't get my Brother printer to print from one computer--but it prints okay from the other computer on my network. I need to know the conventions for the Printer Setup Utility.
    There's a checkbox by every printer on the list. What does it mean when the checkbox is grayed out?
    Some printer names appear in bold. What does that mean?
    Thanx.

    Thank you for your reply. I appreciate your help in this and just want to understand what you're saying.
    As I say, the printer is displayed in the print dialog box but the checkbox is grayed out. I'm assuming that when you say "...it can't find/see them now," you mean the print dialogue can't see them (the drivers). Your last sentence confuses me. You say, "Do you maybe have Printer Sharing enabled & they aren't actually directly connected? If so you have to reboot after turning it off." A little confusion about your antecedents here. What isn't actually connected? The printer? So I have to reboot after turning it off, "it" I suppose is the printer, is that right? I will try that. So turn printer off, reboot, turn printer on. Right?
    I will describe my problem. l thought that if I understood why the checkbox was grayed out I might see what my problem was. If you want me to start another topic I can do that.
    Problem: I have a network with 2 computers and the Brother
    multifunction fax/printer. I'm using an Apple airport hub. The printer
    and one computer (Mac tower) are connected to the airport base via
    ethernet. The 2nd computer (Apple laptop) is on the wireless network.
    Until recently i could print from both computers. Now I can't print from
    the tower. But I can still print from the laptop.
    When I try to print from the tower I get an error message that says, "Cannot print from current printer." I have rebooted, reinstalled printer drivers, checked cables, deleted printer from printer list and re-added printer all to no avail. But as I say, I can still print from the laptop which is using Airport. So the printer prints, the hub connects to the printer okay (ethernet) and I know the tower connects to the hub (I can ping the printer okay from the tower.)
    I am conversing to Brother support via email and their first suggestions I have already tried. Perhaps there's some problem in the network, but I can't figure it out. Worse yet, now when I go to the Network preferences I get an error message which says, "Your network settings have been changed by another application." THIS ERROR MESSAGE WON'T GO AWAY! I can click 'okay' but it reappears. I have to force quit the System Preferences to get out. If you can help with any of these problems I surely appreciate it.

  • AIR Help with printing

    Using AIR output for my Robohelp 8 project and I was having difficulties with the default AIR template.  My difficulities are with the printing inside of the AIR app.  Not sure how it controls printing but the print is 10 times bigger than it should be.  I haven't been able to find any control for the font mapping.
    Any ideas???
    -Will

    Hi there
    Just to note that seldom (if ever) will you get what you want when printing from a viewer designed for on-line presentation.
    Cheers... Rick
    Helpful and Handy Links
    RoboHelp Wish Form/Bug Reporting Form
    Begin learning RoboHelp HTML 7 or 8 within the day - $24.95!
    Adobe Certified RoboHelp HTML Training
    SorcerStone Blog
    RoboHelp eBooks

  • Help with printing a SCORE To PDF! Urgent

    so once again I'm on a deadline and struggling with the score editor. I have a large score. I have been formatting one page at a time, and then moving on. What I mean exactly is that I get page 1 the way I want it, select print and then preview, save as to a PDF, and then move on with page 2 and do the same thing.
    This was working, up until page 13 (ironic). Page 13 had much more going on notes wise, so I dropped the scale of the score set by one percentage point, from 82 to 81%, so that I could still fit everything I wanted on the page and have it look good. But then when I went to print preview, the formatting was all screwed up, and now I can't figure out how to make it look good, while still keeping the decreased scale.
    Please, someone tell me you know how to get around this. It seems like what it says in the manual doesn't apply at all when it comes to preparing a score for printing, and I'm on a deadline for a grant and very frustrated.
    Help?
    Thanks....

    There are 3 ways in which you can affect the size of the Score to Print:
    1) The Page Set up ( which is probably the one you have been using - it may be that below 80% the Score cant be defined in terms of the information on it.. not sure about this)
    2) In the Score Editor if you go to Layout>Create Score Set from Selection and then open Staff Styles.. there is a Scaling Parameter there which reduces/enlarges the Score
    3) In Layout>Staff Styles> You can also change the size of the stave in individual parts which would reduce your Score size
    Hope this is in time for that deadline
    MS
    PS You are correct to print from PDF - printing from the Score Editor will not solve your problem AFAIK
    Message was edited by: musicspirit

  • Problem with .unload from an array

    hello guys,
    i'm really are clueless here pless do help me with this..,
    so i load external swf and store the loader inside an array some of the loaded swf is mine and have method called destroy which used for optimazitation of Garbage COllection and someother are unknown swf (really unknown can be created from as1 or 2 or even 3 i just don;t know anything bout them) the loading and storing does work well.
    Problem came when i tried to unload the the loaded swf,
    so i tried to use SWFArray[i].unload() and all it gives me is :
    Error #2025: The supplied DisplayObject must be a child of the caller
    here is the code i used :
    private function OnSWFLoadComplete(evt:Event):void
         evt.target.removeEventListener(Event.COMPLETE , OnSWFLoadComplete);
         //adding the loaded swf to it's container movieclip and then adding it to the mainContainer
         SWFContainer = new MovieClip();
         SWFContainer.addChild(SWFLoader.content);
         mainContainer.addChild(SWFContainer);
         if(myCounter < (totalSWF-1))
         myCounter++;
         loadSWF();
    the code to load :
    private function loadSWF():void
                   SWFLoader = new Loader();
                   SWFArray.push(SWFLoader);
                   SWFLoader.contentLoaderInfo.addEventListener(Event.COMPLETE , OnSWFLoadComplete);
                   SWFLoader.load(new URLRequest(SWFList[myCounter].@source));
    the code onLoadComplete:
    and after some point i wnat to clear the screen and remove this external swf especially the unknown swf  from the memory not only from the stage
    here is the code i use :
    //removing external SWF that has been loaded
    for(var i:Number = 0; i < totalSWF; i++)
         //some of the loaded swf is created by myself and have method/function called "destroy"
         //and the rest are totally unknown
         if (SWFArray[i].content.destroy)
              SWFArray[i].content.destroy();
         mainContainer.removeChildAt(0);
         SWFArray[i].unload();
    this.stage.removeChild(mainContainer);
    the line that is italized,bold, underlined are the one that i suspect cause the error..,
    so can anyone help me solve this..,
    or even tell me how to unload this dynamicly loaded external swf??
    thanks in advanced guys

    Andrei1 wrote:
    I missed the fact that you do remove listeners.
    The main point of my code sample is that it removes only children that exist on display list (while loop). Based on your original post it seems like the reason for the error is that you attempt to remove objects that are not on display list at the time you call removeChild().
    nope the problem is definetly has connection with the loader, array and way to acces the .unload() from an array..,
    why i so persistent about this??
    because if i simply don't use the line "SWFArray[i].unload()"
    and i did change the code into  :
    private function loadSWF():void
                   var SWFLoader = new Loader();
                   SWFArray.push(SWFLoader);
                   SWFLoader.contentLoaderInfo.addEventListener(Event.COMPLETE , OnSWFLoadComplete);
                   SWFLoader.load(new URLRequest(SWFList[myCounter].@source));
    and still having the same problem..,

Maybe you are looking for

  • Can not filter the data with the extended class

    Hi, I have a quick question about PortableObject format. I have created a class which extends PortableObject interface and implemented serializer methods as well. I have updated it in the pof-config.xml file as well. If I insert the objects of this t

  • Exception in calling web service from OAF page.

    Hi, I am trying to invoke a web service from OAF. But my code error out at particular statement where I am sending the message i.e. at SOAPMessage reply = connection.call(message, destination); The error message is java.security.privilegedactionexcep

  • Netflix "Recently Watched" gone after ATV update?

    Help! What happened to the Recently Watched section in the Netflix app? This section was crucial for easily keeping up with series  you were watching.  Please Apple bring it back! Anyone know of a way to get this back?

  • Sending bytes issue

    Hi I am implementing an echo server and a client to measure RTT and throughput of a TCP link. I have been provided with a detailed protocol the server and client must follow. Here is the problem: The server at a certain point will be waiting for the

  • Serial number status problem

    Dear all, I have the following problem: A material (serial number relevant) was sent out with a delivery and came also back with a return delivery. This means we have it back in stock. The status of the serial still says "Assigned to delivery". Now I