Lots of blank space when printing array with only last element printed

I have a slight problem I have been trying to figure it out for days but can't see where my problem is, its probably staring me in the face but just can't seem to see it.
I am trying to print out my 2 dimensional array outdie my try block. Inside the trying block I have two for loops in for the arrays. Within the second for loop I have a while to put token from Stringtokeniser into my 2 arrays. When I print my arrays in this while bit it prints fine however when I print outside the try block it only print the last element and lots of blank space before the element.
Below is the code, hope you guys can see the problem. Thank you in advance
   import java.io.*;
   import java.net.*;
   import java.lang.*;
   import java.util.*;
   import javax.swing.*;
   public class javaflights4
      public static final String MESSAGE_SEPERATOR  = "#";
      public static final String MESSAGE_SEPERATOR1  = "*";
      public static void main(String[] args) throws IOException
         String data = null;
         File file;
         BufferedReader reader = null;
         file = new File("datafile.txt");
         String flights[] [];
               //String flightdata[];
         flights = new String[21][7];
         int x = 0;
               //flightdata = new String[7];
         int y = 0;
         try
            reader = new BufferedReader(new FileReader(file));   
            //data = reader.readLine();   
            while((data = reader.readLine())!= null)   
               data.trim();
               StringTokenizer tokenised = new StringTokenizer(data, MESSAGE_SEPERATOR1);
               for(x = 0; x<=flights.length; x++)
                  for(y = 0; y<=flights.length; y++)
                     while(tokenised.hasMoreTokens())
                        //System.out.println(tokenised.nextToken());
                        flights [x] [y] = tokenised.nextToken();
                        //System.out.print("*"+ flights [x] [y]+"&");
               System.out.println();
            catch(ArrayIndexOutOfBoundsException e1)
               System.out.println("error at " + e1);
            catch(Exception e)
            finally
               try
                  reader.close();
                  catch(Exception e)
         int i = 0;
         int j = 0;
         System.out.print(flights [j]);
//System.out.println();

A number of problems.
First, I bet you see a lot of "error at" messages, don't you? You create a 21x7 array, then go through the first array up to 21, going through the second one all the way to 21 as well.
your second for loop should go to flights[x].length, not flights.length. That will eliminate the need for ArrayIndexOutOfBounds checking, which should have been an indication that you were doing something wrong.
Second, when you get to flights[0][0] (the very first iteration of the inner loop) you are taking every element from the StringTokenizer and setting flights[0][0] to each, thereby overwriting the previous one. There will be nothing in the StringTokenizer left for any of the other (21x7)-1=146 array elements. At the end of all the loops, the very first element in the array (flights[0][0]) should contain the last token in the file.
At the end, you only print the first element (i=0, j=0, println(flight[ i][j])) which explains why you see the last element from the file.
I'm assuming you have a file with 21 lines, each of which has 7 items on the line. Here is some pseudo-code to help you out:
count the lines
reset the file
create a 2d array with the first dimension set to the number of lines.
int i = 0;
while (read a line) {
  Tokenize the line;
  count the tokens;
  create an array whose size is the number of tokens;
  stuff the tokens into the array;
  set flights[i++] to this array;
}

Similar Messages

  • Crash when use indexe array with in place element structure

    Hello !
    I have a problem with in place element structure. I want index a waveform array (16 elements) and when i execute or save that labview close....
    I dont have problem with waveform array 15 elements or less, but i need index 16 elements...
    Thanks for your help !!!
    Solved!
    Go to Solution.
    Attachments:
    Test.PNG ‏8 KB

    I give you my code but it work because i used a waveform array with only 15 elements. I can't save or execute with 16 elements...
    So add it (like picture Test.png) and you will see.
    Thank you
    Attachments:
    Test.vi ‏25 KB

  • Why do graphics and colors that appear on the monitor show up as blank spaces when printed out

    Graphics (especially color) on emails and attachments show up as BLANK spaces when printed out.
    Also, some color graphics and detail work of those graphics on familiar websites do not show up on my monitor
    Both of these situations DO NOT occur on Explorer. With that browser - everything is OK

    it may have worked, but gimping my system isn't exactly a solution, more of a band-aid.
    its the equivalent of the old
    patient says, " its hurts when i do *this* "
    doctor replies," well, don't do that "
    What do you mean "it may have worked" – did it or did it not?
    Anyway it is not a remedy but diagnostics and if it makes a difference it points at the GPU driver as a likely culprit.

  • How do I start with a circular blank space to be filled with text/pic?

    How do I start with a circular blank space to be filled with text/pic? All info I can find relates to rectangular shapes.Max

    Many thanks
    Max Emmons
    Date: Sat, 8 Jun 2013 09:30:22 -0700
    From: [email protected]
    To: [email protected]
    Subject: How do I start with a circular blank space to be filled with text/pic?
        Re: How do I start with a circular blank space to be filled with text/pic?
        created by hatstead in Photoshop Elements - View the full discussion
    Max,
    Open your picture fileAccess the cookie cutter tool in the toolbox. On the tool's option bar, click on the fly-out for the crop shapes. Select the circular shape (it's all black). Hold down the shift key on the keyboard and drag out the circle to embrace what you wish to retain. You can drag the circle to adjust further, then crop.
    To add text, get the type tool and type the text. This will be on a separate layer. Note that there are areas of transparency (checkerboard pattern) outside the circlular area.
    Use the Paintbucket tool to fill these areas. The tool uses the foreground color.
    Another option would be to place a layer below the circle layer and fill it with a pattern or whatever you want.
    Feel free to repost if this is not clear.
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5390309#5390309
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5390309#5390309
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5390309#5390309. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Photoshop Elements by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • When I select print from any website article while in Firefox it only prints a blank page. When I open same web pages using Safari, they print fine. Documents in other appliations print fine. Only Firefox documents print blank page.

    When I select print from any website article while in Firefox it only prints a blank page. When I open same web pages using Safari, they print fine. Documents in other appliations print fine. Only Firefox documents print blank page.

    Quit Safari.
    Open the Library folder in your home folder as follows:
    ☞ If running Mac OS X 10.7 or later, hold down the option key and select Go ▹ Library from the Finder menu bar.
    ☞ If running an older version of Mac OS X, select Go ▹ Go to Folder… from the Finder menu bar and enter “~/Library” (without the quotes) in the text box that opens.
    Delete the following items from the Library folder:
    Caches/com.apple.Safari/Cache.db
    Preferences/com.apple.quicktime.plugin.preferences.plist
    Preferences/QuickTime Preferences
    Relaunch Safari and test.

  • How to make 1D Array but with only one element filled in Real Time

    Hi folks,
    here I am with another question. I want to implement an prediction discrete state space observer which is going to run on a CRIO real time target. I am going to do it just like in the example which comes with LV.
    I have some questions regarding the input and outputs which in the example those are "dummy".
    My model is a SISO model, but the function "Construct SS model" returns parameters (A,B,C,D Matrices) as 2D arrays, so once you connect the cluster model into the Discrete Observer model, it takes y and u as 1D arrays despite of the fact that there is a SISO model.
    I realized that the function I am using in the simulations, uses 1D arrays but with only one element filled:
    Does anyone knows how to implement such 1D arrays in Real Time? I guess the way to do it is preallocating one array of zeros of size 1, and then recirculating it through some SR, and replacing the element with my real input and output, but at the dummy.vi, they are using a simple "build array"
    function.

    Ok, I did it that way. But I am facing another problem right now...
    At some point the Discrete Observer return a NAN array, you will see the code in the code snippet?
    I get rid of that component by component, but the observer gets "stuck" in it. So my Control law is zero... but the state stimate is NAN.
    Also I am attaching the VI.
    I do not know why, since in the simulation program all runs well. any thoughts? Maybe the internal numeric precision of the State Space Model?
    Attachments:
    RT - Pole Placement + Complete Observer.vi ‏40 KB

  • I am having trouble printing to an Epson XP600.  It is a new printer and it has been replaced because we thought it was the printer.  Basically, when I print from Excel, only color will print.

    I am having trouble printing to an Epson XP600.  We have replaced the printer and we are still having the same problem.  When I try to print from Excel, only the color prints.  Any suggestions?

    Has anyone else had issues not being able to print black (such as a document)?  My photos print great, but when I try to print a simple black-ink document, it won't work. Any suggestions?

  • Zsh - lots of blank space upon resizing VTE based terminals

    Hello
    I have an issue that is rendering me sleepless these days. It's about zsh and its behaviour when being run inside a VTE based terminal (e.g. gnome-terminal, xfce4-terminal, roxterm, sakura, ...).
    When I increase the terminal height, if the buffer exceeds the window height, the content above won't get correctly shifted down, but simply blank space is added at the bottom.
    On the contrary, when I decrease the terminal height, it does not simply remove the blank space at the bottom, but instead shifts up the buffer, keeping the blank space.
    This is quite annoying, because everytime I resize my windows (which happens quite often, as I'm in a tiling WM), I find myself scrolling up in order to see older output because there's only one line remaining. And even worse, as I start typing, it all scrolls back down, even though I type within the visible area.
    This does not happen upon running another shell (bash, dash), or zsh in a non-VTE terminal (urxvt, xterm), however I'd like to stay with zsh and xfce4-terminal (as I'm having lots of other issues with urxvt).
    After hours of googling, I haven't found any entry about a similar problem, which I find slightly confusing, since one of my friends has exactly the same behaviour with xfce4-terminal and zsh (he just hasn't noticed until I asked him, as he doesn't resize his terminal windows that often).
    My question(s):
    Does anybody else use zsh in a VTE-based terminal? And if so, do you get the same behaviour? And if not, could you help me out with your configuration?

    ayekat wrote:
    linvinus wrote:in zsh it hardcoded,
    you can check that if you run zsh inside script (script — make typescript of terminal session)
    Oh, you're right. It always prints \e[J before printing a new prompt. I suppose this is due to the 'suggestions-below-the-prompt' thing.
    Thanks for the script command. I learn something new every day ^^
    Now I applied the patch and it works for one half of the problem:
    When I decrease the window size, it correctly eats up the blank space at the bottom (so the text no longer gets pushed upwards).
    However, when I increase the window size, it still adds blank space to the bottom. So basically once a window has been sized down to, say, 10 rows, it will always stay at those 10 rows (except of course there's some new output).
    i think this is normal, but may be you are right.
    i will see what can be done better.
    ayekat wrote:However I just saw that that I've patched the GTK2 version of VTE, perhaps it's better with the vte3 package.
    no it will the same.
    ayekat wrote:
    ... this also explains why some terminals like xfce4-terminal and lxterminal behave as described above, while others like gnome-terminal or roxterm just continue bugging.
    Again, thank you!
    I'll try this afternoon if it works with the vte3 package.
    no problem

  • Blank spaces when @ file_name ?

    Hi SQL and PL/SQL forum,
    vers. info: (64 bit) Oracle10i Enterprise Edition Release 10.2.0.1.0 - Production on Sun/Solaris 10
    How do I permit blank spaces in dirctory name and/or filename when executing a script by
    @[<path>]<file_name> ?
    The following does not work
    @"N:\miniMAKS - etape 3\databaseleverancer\DB-V3-1-0\dokumentation31\scripts31\06 minimakshist\minimaks_05_test.sql"
    Needless to say that leaving out the "" does not work either.
    - Thanks in advance,
    Jens Ole Jensen
    Kort & MatrikelStyrelsen (WWW: http://www.kms.dk)
    Danmark

    Sorry all is still not well,
    I replaced my minimaks_05_test.sql with the real <file_name> being minimaks_05_install.sql. This script contains
    @@"01 DB-V3-001-000 - tabel_kontaktSpec.sql"
    @@"02 DB-V3-001-000 - tabel_eksternrolletype.sql"
    etc.
    the script fails with the same message as I got yesterday
    @@"01 DB-V3-001-000 - tabel_kontaktSpec.sql"
    SP2-0310: Filen "N:\miniMAKS.sql" kan ikke åbnes
    @@"02 DB-V3-001-000 - tabel_eksternrolletype.sql"
    SP2-0310: Filen "N:\miniMAKS.sql" kan ikke åbnes
    etc.
    Oracle® Database Error Messages
    has nothing about SP2-0310.
    It seems like the @@ command forgets the "" around the current directory name.
    My problem is that the naming of <path> and <file_name> is beyound my control.
    Thanks for any advice you may have on this matter.
    Jens Ole Jensen
    Kort & MatrikelStyrelsen (WWW: http://www.kms.dk)
    Danmark

  • Inpufield considering blank space when cursor is placed.

    Hi,
    I have Inputfields in my BSP Application but on some Inputfields, when I place the cursor it starts after one blank space. I have to do Backspace to remove that space and input the entry. Some of the Inputfields are working fine. Issue is with some of them.
    I have compared all but not able to rectify.
    Please let me know if someone faced the similar issue or have any idea.
    Refer the below coding which i have done.
    <htmlb:inputField id      = "if_clmdetl_repairno"
                      type    = "STRING"
                      required = "FALSE"
                      disabled = "<%= disable %>"
                      value    = "<%= v_repair_number %> "
                      design   = "standard"
                      width   = "25%"
                      maxlength = "2"
                      alignment = "FORCEDLEFT"
                      tooltip  = "<%= otr(ZZWTY/REPAIR) %>"/>
    Thanks,
    Rahul

    Replace below code
    <htmlb:inputField id      = "if_clmdetl_repairno"
                      type    = "STRING"
                      required = "FALSE"
                      disabled = "<%= disable %>"
                      value    = "<%= v_repair_number %> "
                      design   = "standard"
                      width   = "25%"
                      maxlength = "2"
                      alignment = "FORCEDLEFT"
                      tooltip  = "<%= otr(ZZWTY/REPAIR) %>"/>
    with this code: Just copy & paste this.
    <htmlb:inputField id      = "if_clmdetl_repairno"
                      type    = "STRING"
                      required = "FALSE"
                      disabled = "<%= disable %>"
                      value    = "<%= v_repair_number %>"
                      design   = "standard"
                      width   = "25%"
                      maxlength = "2"
                      alignment = "FORCEDLEFT"
                      tooltip  = "<%= otr(ZZWTY/REPAIR) %>"/>
    This is what Vijaya says. It will solve the issue & give points to Vijaya if so...
    Raja

  • Why the iPad became blank black when I syn with itunes and it did not work again?

    Why the ipad became blank black when I syn it with itunes of the desk top.  It did not work since then.

    Have you tried a reset ? Press and hold both the sleep and home buttons for about 10 to 15 seconds, after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • Display "blank-out" when using Maya with a GF 7800?

    I have a problem where my LCD display occasionally blinks off for about 5-10 seconds when using Maya with a scene displaying about 100,000 polys. Has anyone else encountered this? This only seems to happen when I am quickly rotating the camera in a grey shaded perspective panel?
    My LCD is a Dell 20" LCD (set at 1600x1200) connected to a Geforce 7800 in a Quad G5 with 4.5GB of ram.
    I have never seen this issue before in Maya (I have been using Maya for years, on other machines), so I suspect it is hardware or driver related?

    OK, have completed several tests. I definately seems that the my Geforce 7800 has problems when running some applications. I wonder if anyone else has encountered this problem?
    The easiest way to cause the display to momentarily shut off is to use Maya in the full screen perspective camera window in shaded mode. Proceed to rapidly move a 20,000 poly model (or greater) both zooming and rotating (the polys need to fill the entire screen and shake the mouse).My display (Dell 20" 2001fp) will blink-off for a few seconds. Of course, this in not "normal" work flow, but I have this issue happening when working normally, it can sometimes take time to occur.
    I have tried the Geforce 6600 (256mb ver) and this does not occur with that video card. I have tried several mice both wired and wireless, plus changed the Energy Saver options for Processor performance (from comments I read on Macintouch.com). The problem is consistent to my Geforce 7800. This problem will also occur in Photoshop CS, by moving images and resizing, but I found it much harder to induce.

  • Unable to Print pages08 with pictures to color printer

    I am not able to print color pages08 documents containing photographs to my HP 4650 color Laser. I am not able to figure this out. The HP 4650 Color Laser has 128 MB's Ram and never gives me a problem with 20-25MB doc's or 50-60MB color photo files.
    The pages file I can not print is a mere 7.6 MB's
    Here's the steps I've taken in my investigation: resaved & remamed the file, resaved & renamed on a different drive w/200 GB's free space. Tossed out my pages08 preferences & restarted (Preferences>com.apple.iwork.Pages.plist), and repaired my colorSnyc profiles. After each/all of these I have no luck printing to my HP 4650 color Laser.
    Next I created a 3.8MB pages08 test document with 4 pictures dropped into it from iPhoto6. This test file with 4 pictures is 3.7Mb's. Here's my consistent results
    I can print this document
    - directly from pages08 on my HP 4200 B&W Laser Printer (256MB ram)
    - from Preview as a "reduced file" size pdf (version 5 or lower)
    I can not print this document to my HP 4650 color Printer
    - directly from pages - printer says "20 insufficient memory"
    - directly from Preview - printer says "20 insufficient memory
    Next, I exported from iphoto6 the same 4 pictures (in original dimensions) to Photoshop & InDesign.
    I can print this test document on my HP 4650 color
    - directly from Photoshop (.psd file size is 27.8MB)
    - directly from Indesign (.indd file size is 2.2MB)
    Next, I used the "Template Choose">"Extreme"
    - OK printing template (as is) directly to HP color before & after saving
    - NO printing after adding 4 different pics using iphoto6
    - NO printing after adding 3 different pics using iphoto6
    - NO printing after adding 2 different pics using iphoto6
    - NO printing after adding 1 different pics using iphoto6
    What's up?, there seems to be some hidden printing preference here that is limiting me to adding anything to a pages document, or pages is not handling the information properly.
    Any more ideas I can follow? I've never experiences an insufficient memory issues in any other applications with any other documents other applications.

    I've replaced the HP printer driver and had no change, my pages08 documents with picture(s) added will still not print.
    I can print the pages08 templates as they exist, but when I add or replace even one picture (using iPhoto) the document will not print to my HP Color printer yet will print on my HP B&W printer.
    Additionally, I can add 10-20 more pictures and the B&W printer continues to print perfectly. HP claims this is an application program and not the trouble of their printer. I have to agree since only pages document with pictures is my culprit, every program and every massive size document I want to print
    There seems as if an invisible limit exists that I surpass when I add a picture. Are there any preferences or settings I've missed, a cache I should clear?
    Aside from upgrading to pages09, I hope you can assist with some helpful remedies, thank you.

  • Adding Print Button With Java Script to Print of Different Pages Differently

    Hi,
    I am in the process of making a form and most of it is done and now I want to be able to print off two of the pages but to different printers, I have one that needs to be printed off on a regular A4 printer and another that needs to go to a label printer. I have both of the names for the printers and I have tried something but it just doesnt do anything at all (this is suggested by adobe I think?)
    var pp = this.getPRintParam();
    var printamount = this.getValue("Quantity_Boxes");
    pp.printerName = "Zebra Technologies ZTC GK420t";
    pp.firstPage = 3;
    pp.lastPage = 3;
    pp.NumCopies = 2*printamount;
    this.print();
    I tried it without the first and last page and nothing happens, I am useing a shared printer which works when I do cmd + P which the full printer name is Zebra Technologies ZTC GK420t @ User's iMac. (I have also tried putting the full name in aswell)
    This is just to test one page so far but is there any way that one button will be able to print off 2 different pages to 2 different printers?
    If someone knows how this would be a great help!
    Thanks,
    Bruce

    Thanks for that, I have it working now but it shows the dialog box with no settings changed should i use:
    pp.interactive = pp.constants.interactionLevel.automatic ?
    Thanks,
    Bruce
    EDIT:
    It printed but only the first page but it printed on the right amount quantity was 2*3 wich was the result of the Quantity_Box value
    I want it to print page 3 through the Zebra Printer and have page 2 printed to a different printer, is this possible through one button?

  • Smart form printing issue with LOCL and SAP printer

    Hi,
    The issues are as follows:
    1. the top portion of the Invoice and PO does not print when using the SAP printer (works when using LOCL)
    2. the shaded areas of the Order Confirmation and Invoice are black when printing to a SAP printer (works when using LOCL)
    In an attempt to correct the printing issue is was suggested that we change the SAP printer device type from HPLJ4 to POST2. This did address the problem where the shaded areas were black but then we received reports that other reports printed "garbage". Its possible that using POST2 device type causes issues when printing to HP compatible printers.
    Apparently all the testing was done using the SAP printer LOCL and not the SAP printer name and SAP spool system. LOCL uses the SAP GUI and Windows system to produce the output. Our production users at the plant site and Toledo are using SAP defined printers with the device type of HPLJ4. HPLJ4 is our standard here as OC for our printer definitions and we have HP compatible printers installed in our Toledo location and all of our remote sites. We need to be able to correctly print the Invoices, Purchase Orders, Sales Order Confirmations on our SAP printers.
    What can be done to the reports to allow them to print on our HPLJ4?
    Thanks, Prathap

    Hi Prathap,
    Check the background shading of the windows of the Smartform where you get the black boxes. If it is set something like this:
       Color: White
       Saturation: 100%
    this can be the problem.
    I know it is strange but some black and white printers cannot handle this setting. They only know one color black so the ignore the color setting and just take the saturation 100% setting.
    The reason it works with local and device type SAPWIN is that the print data is created in Windows and sent to the printer as graphic.
    Please change the shading for window MAIN -> tab 'Output Options' to:
       Color: Black
       Saturation: 0%
    and this should resolve the problem.
    Then create a new spool and check if the problem is resolved. See SAP Note #400050.
    Regards,
    Aidan

Maybe you are looking for