Please help using substring()

char[] data = new char[80];
            int len = 0;
            while ((len = br.read(data, 0, data.length)) != -1 ) {
                //You do now have len characters available in the data.
                 line = new String(data, 0, data.length) + ",";
                 String firstName = line.substring(0,10) + ",";
                 String lasttName = line.substring(10,27) + ",";
                 String startDate = line.substring(27,35) + ",";
                 String address1 = line.substring(35,45) + ",";
                 String address2 = line.substring(45,55) + ",";
                 String city = line.substring(55,65) + ",";
                 String state = line.substring(65,67) + ",";
                 String country = line.substring(67,70) + ",";
                 String zip = line.substring(70,80);
                 String record = firstName+lasttName+startDate+address1+address2+city
                                          +state+country+zip;
            } I'm reading is a file with the code above, and then breaking the lines up into substrings manu with different sized fields. Using this sample input file:
Bob Smith 12 North Rd Denver CO USA 12435
Tom Jones 82 State St Miami FL USA 95764
It reads in the first line fine (Bob, Smith, 12 North Rd, Denver, CO, USA, 12345), but the second line doesn't formatting like it should (ex: Jo,nes 82, State St Mi,ami ...etc)
My guess is that maybe the last element may be causing the problem as in its reading the zip and reading out to 10 chars, but the zip is only 5, and I believe it mayb be overlapping and starting to read the next line somehow.
Any help would be GREATLY appreciated.

From the API documentation:
Returns:
The number of characters read, or -1 if the end of
the stream has been reached. I'm assuming this is regarding the read(byte[]) method of BufferedInputStream?
So how does it know it's reached the end of the
stream(-1) if the actual end of the stream is beyond
80 characters?If there is nothing to read when you call read() then it will return -1. If there is anything to be read, it will return the number of characters read.
I'm asking because I don't know the answer, which I
believe is the solution.No, this has nothing to do with the solution to your problem. The problem is that you're reading to much at a time, you should only read one line at a time.

Similar Messages

  • Please help using Helix Tookit for Wpf

    Im using helix 3d toolkit for wpf and i want to plot a surface parametrically given the arrays
    x[u,v],y[u,v],z[u,v]
    here u and v are the parameters of the surface. I looked at the surfaceplot demo and couldnt figure it out please help thanks.

    Unfortunately, since this is third party, not supported by Microsoft.
    That means that msft are unlikely to offer advice.
    You might get lucky and find someone here has used it - not looking good so far though.
    Otherwise, you are best advised to ask on stack overflow as the documentation says:
    https://helixtoolkit.codeplex.com/discussions
    Good luck.
    Hope that helps
    Please don't forget to upvote posts which you like and mark those which answer your question.

  • Please help me : SUBSTR function in Oracle 6i

    Dear all people!
    I have a problem with SUBSTR as follow:
    my code:
    declare
    string1 varchar2(300);
    string2 varchar2(65);
    begin
    string1 := ....
    string2 := substr(string1,1,60);
    end;
    when i run program in debug
    at command "string2 := substr(string1,1,60);" it raise error ORA-06502;
    Please tell me how to assign substr(string1,1,60) to string2 (max length of string2 is 65);
    I'm looking to forward to receiving your response!
    Thank you very much;

    The question was simple:
    I am trying to do is bring in anything after the * in the Id column no matter how long the name is before the * but my calculation is way off L:
    Here is an example of what my data would look like but what I need it to do:
    Id                                                        NEW COLUMN
    TNET*231333                                  231333
    AMER*29283893.2                       29283893.2
    TNEY*21893838                             21893838
    Do you know how to create this calculation?
    Answer: SUBSTR(id,INSTR(id,'*',1)+1,999)
    this was emailed to me from someone on here saying "try to see if this helps" and it did that's why i said thank you.

  • Please help, used my credit card

    Hello
    Maybe somebody could tell me how to contact with skype with this problem? Somebody used my credit card or online banking to pay for his skype account. How should I contact with skype to get information about account witch was paid?

    you may need to contact Skype's customer service as well as your bank to know what your possible options are;
    How to Contact Skype Customer Service
    IF YOU FOUND OUR POST USEFUL THEN PLEASE GIVE "KUDOS". IF IT HELPED TO FIX YOUR ISSUE PLEASE MARK IT AS A "SOLUTION" TO HELP OTHERS. THANKS!
    ALTERNATIVE SKYPE DOWNLOAD LINKS | HOW TO RECORD SKYPE VIDEO CALLS | HOW TO HANDLE SUSPICIOS CALLS AND MESSAGES
    SEE MORE TIPS, TRICKS, TUTORIALS AND UPDATES in
    | skypefordummies.blogspot.com | 

  • Please Help using BAPI_TRANSACTION_COMMIT in BDC session

    Hi,
      I am using custom transaction to create vendor invoices by using function module BAPI_INCOMINGINVOICE_CREATE and it creates the invoice and go to BAPI_TRANSACTION_COMMIT to commit the database updates. 
    The problem is when i am creating the invoice for multiple PO's using BDC session method this program executes only of one PO's and commits created invoice data and comes out of the program with out continuing to further steps after BAPI_TRANSACTION_COMMIT FM execution. Please advise me how to resolve this.
    Regards,
    Challa

    Hello Challa
    The command
    CALL TRANSACTION USING...
    has to optional addition
    OPTIONS FROM ls_options.
    where ls_options is of type CTU_PARAMS.
    In the documentation of CALL TRANSACTION is says that if RACOMMIT = 'X' then CALL TRANSACTION USING... is not completed by COMMIT.
    I guess the commit work does prematurely finish your BDC session if this option is initial.
    Regards
       Uwe

  • Please help: Using integration transformation

    Hello,
    I have the following xml:
    <params>
    <param>
    <name>parameter1</name>
    <value>somevalue</value>
    </param>
    <param>
    <name>parameter2</name>
    <value>somevalue</value>
    </param>
    </params>
    This XML is the entry point of my process. I want to select, for example, parameter2 and set process String variable named "parameter2" with the xml value.
    When I set transformation using workshop I get the following source code:
    data($x0/ns0:param[1]/ns0:value)
    But I want to select "parameter1", not the element 1 of the XML. How I can do this using workshop?
    Thanks
    Srp.

    The transformation you need is based on condition, you want to traform data based on the value of another tag, so you need to define if statement, something like -
    if ($x0/ns0:param[1]/ns0:name = "parameter1") then
    data($x0/ns0:param[1]/ns0:value)

  • So how can I use my iPhone or stream music on the ATV without having use of the computer?. I am limited I have wifi iPhone ATV and hd TV. My ATV has a setting for AirPlay as well. Please help :)

    So how can I use my iPhone or stream music on the ATV without having use of the computer?. I am limited I have wifi iPhone ATV and hd TV. My ATV has a setting for AirPlay as well. Please help :)

    Use AirPlay.

  • Query Performance Please Help

    Hi can any body tell me how do I improve the performance of this query.This query takes forever to execute.
    PLEASE HELP
    select substr(d.name,1,14) "dist",
    sum(r.room_net_sq_foot) "nsf",
    sum(r.student_station_count) "sta",
    sum(distinct(r.cofte)) "fte"
    from b_fish_report r,
    g_efis_organization d
    where substr(r.organization_code,-2,2) = substr(d.code,-2,2) and
    d.organization_type = 'CNTY' and
    r.room_satisfactory_flag = 'Y' and
    substr(d.code,-2,2) between '01' and '72'
    -- rownum < 50
    group by d.name, r.organization_code
    order by d.name
    It has nonunique Indexes on Organization code
    Thanks
    Asma.

    Asma,
    I tried your SQL on my tables T1 and T2. Indexes are on C1,C2,C3 and N1,N2,N3. The data in T1 and T2 are shown below with the explain plan (also called EP) listed. You really need to do an explain plan (free TOAD is easiest to do this in) and respond showing your EP results.
    By simply changing the optimizer mode to RULE I was able to get it to use indexes on both T1 and T2.
    T1 data
    C1     C2     C3     N1     N2
    001     Y     AAA     1     11
    002     Y     BBB     2     22
    003     Y     CCC     3     33
    111     N     DDD     4     44
    222     N     EEE     5     55
    333     Y     FFF     6     66
    070     Y     GGG     7     77
    071     N     HHH     8     88
    072     Y     III     9     99
    TEST     TEST     TEST     10     100
    T2 data
    C1     C2     C3     N1     N2
    001     CNTY     AAA     1     11
    002     CNTY     BBB     2     22
    003     CNTY     CCC     3     33
    111     XXX     DDD     4     44
    222     XXX     EEE     5     55
    333     CNTY     FFF     6     66
    070     CNTY     GGG     7     77
    071     XXX     HHH     8     88
    072     CNTY     III     9     99
    TEST     TEST     TEST     10     100
    This is the results when I run the SQL based on this data ...
    dist     nsf     sta     fte
    AAA     1     11     10
    BBB     2     22     20
    CCC     3     33     30
    FFF     6     66     60
    GGG     7     77     70
    III     9     99     90
    --[SQL 1] : with CHOOSE as the optimizer mode, which is normally the DEFAULT if no hint is specified
    select /*+ CHOOSE */
    substr(d.c3,1,14) "dist",
    sum(r.n1) "nsf",
    sum(r.n2) "sta",
    sum(distinct(r.n3)) "fte"
    from t1 r, t2 d
    where substr(r.c1,-2,2) = substr(d.c1,-2,2) and
    d.c2 = 'CNTY' and
    r.c2 = 'Y' and
    substr(d.c1,-2,2) between '01' and '72'
    group by d.c3, r.c1
    order by d.c3
    This is what the EP shows for your SQL (which will probably be the same for you once you do an EP on your actuall sql) ...
    SELECT STATEMENT Optimizer=CHOOSE (Cost=4 Card=1 Bytes=37)
    SORT (GROUP BY) (Cost=4 Card=1 Bytes=37)
    NESTED LOOPS (Cost=2 Card=1 Bytes=37)
    TABLE ACCESS (FULL) OF T1 (Cost=1 Card=1 Bytes=12)
    TABLE ACCESS (BY INDEX ROWID) OF T2 (Cost=1 Card=1 Bytes=25)
    INDEX (RANGE SCAN) OF I_NU_T2_C2 (NON-UNIQUE)
    Notice the FULL table scan of T1 which you don't want, and neither C1 index is getting used (I've explained why below).
    --[SQL 2] : only changed the hint to RULE ...
    select /*+ RULE */
    substr(d.c3,1,14) "dist",
    sum(r.n1) "nsf",
    sum(r.n2) "sta",
    sum(distinct(r.n3)) "fte"
    from t1 r, t2 d
    where substr(r.c1,-2,2) = substr(d.c1,-2,2) and
    d.c2 = 'CNTY' and
    r.c2 = 'Y' and
    substr(d.c1,-2,2) between '01' and '72'
    group by d.c3, r.c1
    order by d.c3
    SELECT STATEMENT Optimizer=HINT: RULE
    SORT (GROUP BY)
    NESTED LOOPS
    TABLE ACCESS (BY INDEX ROWID) OF T2
    INDEX (RANGE SCAN) OF I_NU_T2_C2 (NON-UNIQUE)
    TABLE ACCESS (BY INDEX ROWID) OF T1
    INDEX (RANGE SCAN) OF I_NU_T1_C2 (NON-UNIQUE)
    Though the C2 index is getting used (your r.c2 = 'Y' part in the where clause) the main problem your having here is the JOIN column (C1 in both tables) is not getting used. So the join you have ...
    where substr(r.c1,-2,2) = substr(d.c1,-2,2)
    isn't using an index and you want it too. There are 2 solutions to correct this..
    Solution #1
    The first is to make a function-based index for data. Since your doing SUBSTR on C1 that C1 index does not contain that partial information so it will not use it. Below is the syntax to make a function based index for this partial data ...
    CREATE INDEX I_NU_T1_C1_SUBSTR ON T1 (SUBSTR(C1,-2,2));
    CREATE INDEX I_NU_T2_C1_SUBSTR ON T2 (SUBSTR(C1,-2,2));
    or also this way if it's still not using the above indexes ...
    CREATE INDEX I_NU_T1_C1_SUBSTR ON T1 (SUBSTR(C1,-2,2),C1);
    CREATE INDEX I_NU_T2_C1_SUBSTR ON T2 (SUBSTR(C1,-2,2),C1);
    Solution #2
    The second solution is to make another column in both table and place this 2 digit information in it, and then index this new column. That way the join will look like ...
    where r.c_new_column = d.c_new_column
    and
    r.c_new_column between '01' and '72'
    also with this new column the BETWEEN clause at the end you will not need the substring as well. Also remember BETWEEN on character values is different than numbers.
    Final Notes
    I just tried creating the functional index and I can't get it to be used it for some reason (I might not have the right amount of data), but I really think that is your best option here. As long as it uses the functional index you won't have to change your code. You might want to try using INDEX() in the hint to get it to be used, but hopefully it will use it right away. Try all 4 types of optimizer modes (CHOOSE, RULE, ALL_ROWS, FIRST_ROWS) in your primary hints to see if it will use the new function-based index.
    You really do need to get explain plan going. Even if you make these functional indexes you won't know if its going to be using them until you look at the EP results. You can do EP manually (the SQL of how to produce the results is in OTN, though I find free TOAD is by far the easiest) and you will still need to have run the utlxplan.sql script. Oracle I do think has some GUI tools, maybe in OEM, that have explain plan built in as well.
    I hope this helps ya,
    Tyler D.

  • Adobe Reader for Android issue.... Please help!

    When I open certain pdf files on my HTC Evo they open appear completely blank. Does this have something to do with security settings? If so how to I fix it? I am able to open these files just fine on my pc! This is so frustrating. Please help.

    Use the forum 'Adobe Reader for Android'.

  • Please help with Layer Mask

    I have been painting in Photoshop using layer masks. Using the pen tool I would outline my image, control>R-click>select create layer mask, then I would paint as desired. When doing so it would create a grey layer mask background in the layers window and everything would work100%. But now all of a sudden when I do this process the layer mask square turns white and it seems as the mask I have created is inverted. I paint everything but the mask I want. I have no clue how to turn it back to the original grey colour I was using. Please help.

    Using the pen tool I would outline my image, control>R-click>select create layer mask,
    So are you using a Vector Mask or a Layer Mask?
    Could you post a screenshot?
    What are the Paths’ Area settings?

  • HT203164 My newly installed burner works fine from i-tunes, except the burned disk won't work in my car CD player. The old burner's disks work just fine in the car. Please help.

    My newly installed burner works fine from i-tunes, except the burned disk won't work in my car CD player. The old burner's work just fine in the car. Please help.

    Using my new G5 I have the same problem, which I did not know using my old G4 with an external LaCie burner. The CD-Changer in my car is not able to read audio-cds, also my cd-player in my home hifi-system. The only way to play these audio-cds is (strange...) to put them directly in the main tuner of my car (usually used for the navigation cd), not using the Changer.
    Maybe the problem really depends on the quality of the CD-Rs. I have used CD-Rs from Sony (it´s a brand, I think?) and will try Verbatim.
    Regards, Horst

  • I reset my ipad1 to factory settings to put my apple id in instead of my dad's. Now we cannot activate it. We tried connecting it to itunes and to our wifi. We then turned off the ipad and took out the sim card and tried again. nothing worked. Please help

    please help.

    Using FaceTime http://support.apple.com/kb/ht4319
    Troubleshooting FaceTime http://support.apple.com/kb/TS3367
    The Complete Guide to FaceTime: Set-up, Use, and Troubleshooting Problems
    http://tinyurl.com/32drz3d
     Cheers, Tom

  • Substri and instr problem --Please help

    Hi ,
    I would like to get the find tablename starts with 'EXP' using substring and instring . I am using oracle 9i. Please help me out
    Example : 'Schema.explogtable'
    I will use table name ' EXP' in one of my procedure as input parameter to procedure
    If tablename= substr('schema.explogtable','instr('schema.explog','.',1,3) then
    Execute Procedure1('tablename')
    Else
    Execute procedure2('tablename')
    I would appreciate your help
    Regards,
    Clarkc

    ClarkC,
    Here just replace procedure1 and procedure2 with your procedure names;
    create table temp_table
    ( table_name varchar2(30)
    insert into temp_table values ('TESTME.MY_OBJECTS');
    insert into temp_table values ('TESTME.OBJECTS');
    insert into temp_table values ('ABC.ECFOBJECTLOG');
    insert into temp_table values ('XYZ.BDEOBJECTTABLE');
    insert into temp_table values ('ABC.ABCTABLE');
    insert into temp_table values ('ZYD.CLIENTTABLE');
    insert into temp_table values ('NMS.CLIENTLOGTABLE');
    COMMIT;
    pl/sql anonymous blocks  I defined 2 variables for readibility and understanding
    DECLARE
       CURSOR tcur
       IS
          SELECT table_name
          FROM temp_table;
       table_name   VARCHAR2 (40);
       my_table     VARCHAR2 (40);
    BEGIN
       FOR cur IN tcur
       LOOP
          my_table     := NULL;
          my_table     := cur.table_name;
          table_name   := SUBSTR (my_table, INSTR (my_table, '.') + 1);
          IF (table_name LIKE ('%OBJ%'))
          THEN
             DBMS_OUTPUT.put_line ('table_name containing OBJ=' || table_name);
             -- NOTE : CALL YOUR PROCEDURE1 HERE for tables containing OBJ;
            procedure1(table_name);
          ELSE
             DBMS_OUTPUT.put_line('table_name  not containing OBJ=' || table_name);
               -- NOTE : CALL YOUR PROCEDURE2 HERE for tables not containing OBJ;
            procedure2(table_name);
          END IF;
       END LOOP;
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.put_line (SUBSTR (SQLERRM, 1, 300));
          RAISE;
    END;
    Here is the output of the above block
    table_name containing OBJ=MY_OBJECTS
    table_name containing OBJ=OBJECTS
    table_name containing OBJ=ECFOBJECTLOG
    table_name containing OBJ=BDEOBJECTTABLE
    table_name  not containing OBJ=ABCTABLE
    table_name  not containing OBJ=CLIENTTABLE
    table_name  not containing OBJ=CLIENTLOGTABLEHope this helps
    Regards
    Edited by: OrionNet on Jan 17, 2009 11:48 AM

  • Hi Guys,  I am using the full width video widget on a site. The widget was working perfectly however I have just added additional content to the site and re-uploaded and now the video is not working! Please help I have tried everything and am freaking out

    Hi Guys,
    I am using the full width video widget on a site. The widget was working perfectly however I have just added additional content to the site and re-uploaded and now the video is not working! Please help I have tried everything and am freaking out as this web-site has been payed for by my client.
    Alex

    Many thanks.
    With those symptoms, I'd try the following document:
    Apple software on Windows: May see performance issues and blank iTunes Store
    (If there's a SpeedBit LSP showing up in Autoruns, it's usually best to just uninstall your SpeedBit Video Accelerator.)

  • Hi there, I am trying to connect to my server at work from home using a vpn connection. It connects fine and the time ticks along, but when i click go - connect to server, it comes up with connection failed. Please help!

    Hi there, I am trying to connect to my server at work from home using a vpn connection. It connects fine and the time ticks along, but when i click go - connect to server, it comes up with connection failed. Please help!

    ... when i click go - connect to server, it comes up with connection failed.
    If you're trying to connect to a Bonjour server on the remote network, that won't work over a layer 3 VPN. Use something like Hamachi or one of the SSH-tunnelling Bonjour proxy apps for that.

Maybe you are looking for

  • "Mapping not found" Error related to cellular (or slow) connection?

    I have an app that uses ORM rather extensively. For the most part it works like a charm. I only have an intermittent error that seems to occur exclusively when the app is accessed on an iPad using data (as opposed to WiFi). I have users accessing thi

  • Error in the Source System...

    Hi   <b>RSA1-->Source System >(Context Menu)> Check</b> <b>Error:</b> <b>The BW IDoc type ZSBA011 is not the same as the source system  IDoc type ZSBD012                                                                                </b>             

  • HDCP error death

    I started getting the HDCP error recently and have been unable to watch any trailers and the film i rented. After calling Apple support they suggested that my Tv is not HDCP compliant. (Polaroid FLU-2632) it is a new ATV purchased in June 2012 with a

  • Share Beta Updated

    The upgrade is focused on a new Convert to PDF feature, a new user interface and fixing a few critical bugs based on user feedback. After this update you will be able to: - Convert 5 documents to Adobe PDF. - Provide a better viewing experience for d

  • How can I set it up so that clients can respond to the threads in their cases.

    What can be done to allow clients that are logged into the member areas to respond to a case thread that is on going.