Cannot retrieve all vector objects - reading only last line .. Please help

<pre>
When I test the vector in the method that adds the elements, each line is returned. Testing the vector in the method getData(), all items are returned within the while loop, but the test returns only the last line of in the vector. Can anyone help me out and let me know what I'm doing wrong.
Here's a summary of what I'm doing and the code follows.....
My bean class:
- creates a vector and adds several lines to the vector
- using StringTokenizer and Enumeration, parses the data and checks to see if the line has the required amount of tokens (which is 4). If so, then the string is passed to my main class
In the main class, the string is parsed into its appropriate attribute and then the required ones are displayed in the browser.
//Vector class bean
public SpecBean()
public Vector addData()
vecdata.addElement ("3|4||");
vecdata.addElement ("2|3||1200");
vecdata.addElement ("1|2|Q|");
vecdata.addElement ("4|2|U|4356");
return vecdata;
public String getData()
StringTokenizer st;
String record = new String();
Enumeration enumdata = vecdata.elements();
while (enumdata.hasMoreElements())
record = enumdata.nextElement().toString();
System.out.println (record);
st = new StringTokenizer( record, "|");
int numberOfTokens = st.countTokens();
if (numberOfTokens < 4)
record = "Incomplete Data";
return record;
// end class...
//begin main class -- this is a servlet which is why the
//out.println statements are there
try {
SpecBean specs = new SpecBean();
specs.getItemListing();
token = new StringTokenizer ((String)specs.getData(), "|");
out.println ("<table width=\"100%\" border=1>");
out.println("<tr>");
out.println ("<td width=\"40%\">");
while (token.hasMoreTokens())
String id = token.nextToken();
String orderNum = token.nextToken();
String name = token.nextToken();
String confNum = token.nextToken();
out.println (title + "</td>");
out.println ("<td width=\"20%\" align=\"right\">" + "$" + price + "</td>");
out.println ("<td width=\"40%\">" + notes);
//end main class
Thank you.

<pre>
My apologies. What I was looking to do was return EVERY line from the vector that had an equivalent of 4 tokens and no less. I just realized that the sample data I had entered into the vector only had one line w/ 4 tokens. When this is modified and there are 2+ lines that contain 4 tokens, the only line that is retrieved is the very last line. So if the data in the vector was:
public Vector addData()
vecdata.addElement ("3|4|rtd|222");
vecdata.addElement ("2|3||1200");
vecdata.addElement ("1|2|QsT|");
vecdata.addElement ("4|2|U|4356");
return vecdata;
public String getData()
StringTokenizer st;
String record = new String();
Enumeration enumdata = vecdata.elements();
while (enumdata.hasMoreElements())
record = enumdata.nextElement().toString();
System.out.println (record);
st = new StringTokenizer( record, "|");
int numberOfTokens = st.countTokens();
if (numberOfTokens < 4)
record = "Incomplete Data";
return record;
The output to the browser is
4 2 U 4356
and not
3 4 rtd 222
4 2 U 4356
I did some print statements throughout addData() and getData() to see if all of the objects in the vector were still there and everything checked out until I hit the end of the getData(). Before 'return record' the print statement returned '4 2 U 4356' only. I'm not sure what I have missed to have the getData() method return only one matching line and not all of them.
Your help is appreciated. Thank you.

Similar Messages

  • I've added a pdf to itunes and i want to change it so its visible with an album (digital booklet). But for some reason, when i click get info, its all greyed out and the little box for read only is unticked. please help - urgent! thanks

    I've added a pdf to itunes and i want to change it so its visible with an album (digital booklet). But for some reason, when i click get info, its all greyed out and the little box for read only is unticked. please help - urgent! thanks

    Hi
    My first thoughts are
    • iMovie ill behaving - Trash the iMovie pref file - use to set things right
    • in reg. to Photos - Did You change iPhoto Photo Library - Then iMovie get's lost as it peeks into iPhoto on start up to see where photos are stored. Set iPhoto back to first Photo Library (when iMovie is not running) then start iMovie.
    Yours Bengt W

  • How to retrieve data from a read-only Excel file

    Hi Developers,
    I'm trying to retrieve data from a read-only Excel file. I used the same code that I used to retrieve data from a normal Excel file, but it can't work.
    My code is as followed:
    try
    InputStream KpExcel = new FileInputStream("kp.xls");
    HSSFWorkbook Kpwb = new HSSFWorkbook(KpExcel);
    HSSFSheet Kpsheet = Kpwb.getSheetAt(0);
    catch(Exception e)
    e.printStackTrace();
    System.out.println("Exception: "+e.getMessage());
    The error I received is as followed:
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:224)
    at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:160)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:163)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:210)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:191)
    at photoproductionsystem.IncomingWIPPanel.getKp(IncomingWIPPanel.java:118)
    at photoproductionsystem.IncomingWIPPanel.<init>(IncomingWIPPanel.java:76)
    at photoproductionsystem.TabbedDisplay.<init>(TabbedDisplay.java:47)
    at photoproductionsystem.Display.create(Display.java:73)
    at photoproductionsystem.Display.init(Display.java:44)
    at photoproductionsystem.Display.main(Display.java:229)
    Caused by: java.lang.ArrayIndexOutOfBoundsException
    at java.lang.System.arraycopy(Native Method)
    at org.apache.poi.hssf.record.UnknownRecord.<init>(UnknownRecord.java:62)
    at org.apache.poi.hssf.record.SubRecord.createSubRecord(SubRecord.java:57)
    at org.apache.poi.hssf.record.ObjRecord.fillFields(ObjRecord.java:99)
    at org.apache.poi.hssf.record.Record.fillFields(Record.java:90)
    at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
    at org.apache.poi.hssf.record.ObjRecord.<init>(ObjRecord.java:61)
    ... 15 more
    Can someone please help me with my problem? Thanks a lot in advance!

    Madeline wrote:
    how do I ask at Apache mailing list?I wonder why it seems to be a strange idea to some people to look at the software vendor's site for product support. :p
    http://poi.apache.org/mailinglists.html

  • All folders changed Read Only

    Okay, so recently, just about all my folders (including every subfolder in iTunes and the such) have become read only. So whenever i try to change something, i need to set that folder back to read and write for Me. This is very annoying, and I don't know what happened to make all the folders read only.
    Is there some way to change all the permissions on my disk back to Read and Write for Me (the administrator) without going through every single folder?

    first, whatever you do, don't try to make everything on your hard drive read+write for yourself. this will invariably brick the system and you'll have to reinstall. there is no other outcome possible.
    where exactly are the problem files located? only in your itunes folder? somewhere else in your home directory? what exactly does the permissions panel for such files say?

  • How to only read the last line in the text file by using BufferedReader ?

    Dear all,
    Hello, I am new to Java. Do anybody know how to read the last line (this is the last record) in the text file.The method I am now using is reading from the first line until I reach the last line in the text file. Thank you!!
    BufferedReader br = new BufferedReader(new FileReader("c:\\sdk1.4.1\\bin\\dbExport.txt"));
    DataInputStream in = new DataInputStream(new FileInputStream("c:\\sdk1.4.1\\bin\\dbExport.txt"));
    String input;
    String firstinput;
    String secondinput;
    int count=90;
    int year=1955;
    while ((input = br.readLine()) != null) {
    firstinput = input.substring(0, 10);
    secondinput = input.substring(10);
    String insertStore1 = ("INSERT INTO AUTHORS " +
    "VALUES ('" + count + "', '" + firstinput + "', '" + secondinput + "', 1955)");
    System.out.println(insertStore1);
    int result = stmt.executeUpdate(insertStore1);

    I suppose you could use a java.io.RandomAccessFile.

  • Best way to make all the items read-only in many pages for a resposibility?

    Hi,
    We have the following requirement:
    We need to make all the fields read-only in 5 standard self-service pages for a particular responsibility. One way is to personalize these pages at responsibility level. Is there any other quick/better way to do it?
    Highly appreciate your suggestions on this.
    thanks,
    Hem

    Hem,
    Personalisation is easiest and fastest way of doing this. The same requirement can be acheieved by extensions of CO by setting the bean properties rr by SPEL binding by extending VO.
    But when I can get something done without coding at all that approach is best, I am sure u agree :)!
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • All SD cards read only

    Both the internal Sd reader on my iMAC and a usb external reader read all cards as read/only.  If you go to get info, you can't change this setting.  In Disk Utility you can't do anything, everything is greyed out. When you insert a card into either reader and then remove it with ejecting, I don't get the error message telling me to eject before removing.
    Any ideas any body?
    Wayne
    <Email Edited By Host>

    There was a thread from 2009 about this problem: it seems that some sd cards (and/or perhaps some sd card slots) get confused, and indicate read only with the switch at either end, but will indicate read/write status with the switch midway between the ends (perhaps a little bit more toward the unlocked end). This sounds strange, I know, but it worked for me today, with a brand new 64GB card (the first one I've ever used in my 21 month old MBP, which indicated read-only with the switch at either end, but became read-write with the switch in the middle.

  • How to read the last line in a text file using text_io?? please help

    Dear all
    I made a procedure that append text into a text file on the operating system.
    the text file grows rapidly. It contains now about 200,000 line . I need to read the last line only . In other wprds i need to go direct to the last line to read some values. Is it possible??
    Please help

    Hello,
    If you know the number of the line you want to read, I can sugget you to use the MORE dos command or the TAIL unix command that redirect to a temporary text file
    Example to create a file that contains the 200010th last lines :
    (Client)Host( 'MORE the_file_name.txt +200010 > small_file.txt') ;So you have only to read the small file with the TEXT_IO functions.
    Francois

  • Printing in only last line item printing in main window

    Hi All,
    My requiremnet is to print same data in two blocks for F110 payment cheque
    Iam using 2 main windows to print same data if block exceeds it will go to next page
    iam calling the windows as shown below
    CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            window   = 'MAIN00'
            element  = hlp_ep_element
            function = 'APPEND'
          EXCEPTIONS
            window   = 1
            element  = 2.
        IF sy-subrc EQ 2.
          err_element-fname = t042e-zforn.
          err_element-fenst = 'MAIN00'.
          err_element-elemt = hlp_ep_element.
          err_element-text  = text_525.
          COLLECT err_element.
        ENDIF.
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            window   = 'MAIN01'
            element  = hlp_ep_element
            function = 'APPEND'
          EXCEPTIONS
            window   = 1
            element  = 2.
        IF sy-subrc EQ 2.
          err_element-fname = t042e-zforn.
          err_element-fenst = 'MAIN01'.
          err_element-elemt = hlp_ep_element.
          err_element-text  = text_525.
          COLLECT err_element.
        ENDIF.
    Iam getting only last line item printing in main window
    Please provide the inputs.
    Thanks,
    Kamalakar.
    Please use code tags.
    Edited by: Rob Burbank on Nov 25, 2011 11:51 AM

    Hi,
    My requirement was to print same block twice in cheque printing of F110.
    I have used the function module  'WRITE_FORM_LINES' to print more than one line item in secondary window in the script .
    fill the Lines internal table as shown below.
    Example :
        lines-tdformat = 'TM'.
        CONCATENATE regup-xblnr ',,' w_date ',,'  w_bsak-sgtxt ',,' w_gross ',,' w_dis ',,'
        w_net INTO lines-tdline.
    APPEND lines.
    CALL FUNCTION 'WRITE_FORM_LINES'
          EXPORTING
           function                       = 'APPEND'
           header                         =  header_t
           type                           = 'BODY'
           window                         = 'MAIN01'
        IMPORTING
          FROMPAGE                       =
          PENDING_LINES                  =
          TABLES
            lines                          = lines
         EXCEPTIONS
           function                       = 1
           type                           = 2
           unopened                       = 3
           unstarted                      = 4
           window                         = 5
           bad_pageformat_for_print       = 6
           spool_error                    = 7
           codepage                       = 8
           OTHERS                         = 9
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF.

  • My iPhone 4S was replaced yesterday due to my handset being faulty. Before I gave the faulty one back I made sure all pictures were in photo stream! All 1006 were however when I got home and set up my new handset, there's only 146. Please help??

    I received my new iPhone 4S today due to the last one being faulty. I had 1006 pictures in my photo stream however on setting my new phone up I only have 146 :( please help?

    Had this problem before. sometimes it's the network. downloading all the photos take time.If you r so sure 1006 pics are in the photo stream, then no need to worry. It'll come. Give it time. Good things take time! <wink*>

  • Timemachine only opens a finder window even when I'm in iPhoto or mail. I am trying to retrieve a deleted book project from iPhoto. Please help

    Timemachine only opens a finder window even when I'm in iPhoto or mail. I am trying to retrieve a deleted book project from iPhoto. Please help

    jon199 wrote:
    Timemachine only opens a finder window even when I'm in iPhoto or mail. I am trying to retrieve a deleted book project from iPhoto. Please help
    If you have iPhoto '09, you cannot browse or restore seleted items from your backups.  See the pink box in #15 of Time Machine - Frequently Asked Questions.
    Mail should work, however, per the blue box there. 

  • How to read the last line in a txt file?

    Dear all,
    I want to read the last line in a txt file. There are thousands of lines in this file. What I want is to move the file pointer directly to the last line of the file. But I did not know how do to it. Can anybody help me out?
    Thank you very much!

    If the file is coded as ASCII or one of the encodings that maps a single byte to a char then the following class will assist you
    import java.io.*;
    import java.util.*;
    public class GetLinesFromEndOfFile
        static public class BackwardsFileInputStream extends InputStream
            public BackwardsFileInputStream(File file) throws IOException
                assert (file != null) && file.exists() && file.isFile() && file.canRead();
                raf = new RandomAccessFile(file, "r");
                currentPositionInFile = raf.length();
                currentPositionInBuffer = 0;
            public int read() throws IOException
                if (currentPositionInFile <= 0)
                    return -1;
                if (--currentPositionInBuffer < 0)
                    currentPositionInBuffer = buffer.length;
                    long startOfBlock = currentPositionInFile - buffer.length;
                    if (startOfBlock < 0)
                        currentPositionInBuffer = buffer.length + (int)startOfBlock;
                        startOfBlock = 0;
                    raf.seek(startOfBlock);
                    raf.readFully(buffer, 0, currentPositionInBuffer);
                    return read();
                currentPositionInFile--;
                return buffer[currentPositionInBuffer];
            public void close() throws IOException
                raf.close();
            private final byte[] buffer = new byte[4096];
            private final RandomAccessFile raf;
            private long currentPositionInFile;
            private int currentPositionInBuffer;
        public static List<String> head(File file, int numberOfLinesToRead) throws IOException
            return head(file, "ISO-8859-1" , numberOfLinesToRead);
        public static List<String> head(File file, String encoding, int numberOfLinesToRead) throws IOException
            assert (file != null) && file.exists() && file.isFile() && file.canRead();
            assert numberOfLinesToRead > 0;
            assert encoding != null;
            LinkedList<String> lines = new LinkedList<String>();
            BufferedReader reader= new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding));
            for (String line = null; (numberOfLinesToRead-- > 0) && (line = reader.readLine()) != null;)
                lines.addLast(line);
            reader.close();
            return lines;
        public static List<String> tail(File file, int numberOfLinesToRead) throws IOException
            return tail(file, "ISO-8859-1" , numberOfLinesToRead);
        public static List<String> tail(File file, String encoding, int numberOfLinesToRead) throws IOException
            assert (file != null) && file.exists() && file.isFile() && file.canRead();
            assert numberOfLinesToRead > 0;
            assert (encoding != null) && encoding.matches("(?i)(iso-8859|ascii|us-ascii).*");
            LinkedList<String> lines = new LinkedList<String>();
            BufferedReader reader= new BufferedReader(new InputStreamReader(new BackwardsFileInputStream(file), encoding));
            for (String line = null; (numberOfLinesToRead-- > 0) && (line = reader.readLine()) != null;)
                // Reverse the order of the characters in the string
                char[] chars = line.toCharArray();
                for (int j = 0, k = chars.length - 1; j < k ; j++, k--)
                    char temp = chars[j];
                    chars[j] = chars[k];
                    chars[k]= temp;
                lines.addFirst(new String(chars));
            reader.close();
            return lines;
        public static void main(String[] args)
            try
                File file = new File("/usr/share/dict/words");
                int n = 10;
                    System.out.println("Head of " + file);
                    int index = 0;
                    for (String line : head(file, n))
                        System.out.println(++index + "\t[" + line + "]");
                    System.out.println("Tail of " + file);
                    int index = 0;
                    for (String line : tail(file, "us-ascii", n))
                        System.out.println(++index + "\t[" + line + "]");
            catch (Exception e)
                e.printStackTrace();
    }Note, the EOL characters are treated as line separators so you will probably need to read the last two lines (think about it for a bit).

  • When I try to open iPhoto (9.2.1) it says 'You can't use this version of the application iPhoto with this version of OS X.  All my photos are on there.  Please help.  Thank you

    When I try to open iPhoto (9.2.1) it says 'You can't use this version of the application iPhoto with this version of OS X.  All my photos are on there.  Please help.  Thank you.

    Did you upgrade to a new MacOS X version? Then you need to update iPhoto as well.
    Only iPhoto 9.6 is compatible with MacOS X 10.10 Yosemite.  Update from the Mac App Store.
    Backup your iPhoto library, if you do not have a current backup.
    Launch the App Store, click the "Store" menu, and sign in with your current AppleID.
    Check the "Updates" tab of the App Store for an iPhoto update and run the update.
    When you laugh iPhoto after the update, it will warn you, that the library needs upgrading, That may take a while.
    Just in case that you see a warning, that the update is not possible because of an error message: "This update is not available for this Apple ID either because it was bought by a different user or the item was refunded or cancelled."
    Uninstall iPhoto by deleting it from the Applications folder, but do not empty the Trash, so you can put iPhoto back, if need be.
    Launch the App Store, click the "Store" menu, and sign in with your current AppleID.
    Open the main page "Featured" of the App Store and search for iPhoto.
    If iPhoto is listed as "Free", click the "Free" button to buy it with your current AppleID.
    If it is not showing as free, there is no help but contacting the App Store Support to sort out the AppleID. Use this link: http://www.apple.com/support/mac/app-store/contact/

  • TS3720 I have updated to Mac OS X v10.6.7 and STILL cannot get video into iMovie from Sony HDR SR11 :-(  PLEASE HELP ME ...

    I have updated to Mac OS X v10.6.7 and STILL cannot get video into iMovie from Sony HDR SR11 :-(  PLEASE HELP ME ...

    * Download a new copy of the Firefox program: http://www.mozilla.com/firefox/all.html
    * Trash the current Firefox application to do a clean (re-)install.
    * Install the new version that you have downloaded.
    Your profile data is stored elsewhere in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Firefox Profile Folder], so you won't lose your bookmarks and other personal data.

  • HT201328 Hi, Have updated iphone from 4.3 and had to do a restore which has now rendered my phone useless as it say the sim is not valid. I am in Colombia and this is very frustrating as I cannot just pop to the apple store here. Please Help...

    Hi, Have updated iphone from 4.3 and had to do a restore which has now rendered my phone useless as it say the sim is not valid. I am in Colombia and this is very frustrating as I cannot just pop to the apple store here. Please Help...

    Sounds like you have a phone that was hacked to unlock it. Updating has re-locked it to the original carrier. ONLY the carrier it is locked to can authorize unlocking it. Contact them.

Maybe you are looking for

  • I want to use Berkely database for my Dissertation

    Hello everyone, I am having some doubts regarding Berkely database. Actually, I am using this database for my project. The scenario of the project is, I have developed some business rules depending on the concept of Ripple Down Rules and represented

  • ITunes 7.0.1.8 experiences - Here's what got fixed for me...

    After news of the iTunes 7.0.1.8 update broke out today, I downloaded it and have used it for a little while. I'd thought I'd share my experiences so far, but please take note that I did not do any CD burning/importing tests, nor do I own an iPod to

  • Global Error page in portal

    Hi This is regarding weblogic portal 8.1. We have a portal project which contains several portlets. For handling exceptions in a page flow we have a global error page at the project root level and each portlet redirects to this error page /error.jsp

  • Running a function in a parent at the end of a child.swf

    question: How do I call a function that is inside a parent.swf from a child external swf (class Loader)? In my menu.swf, there is a child (Loader class) of a content.swf that gets loaded below it on run. Then when a button is clicked, it makes a stri

  • Want to store my music and photos on TC. How?

    My macbook Pro is full so i bought a time capsule to back up my computer AND to store my photos and music so I can free up memory. What's the best way to do this and still be able to access my music and photos as if they were still on my computer? Is