Fastest way to loop through a group of strings

I am trying to optimize a small class that loops through an array of strings and compares to see if another string equals one of the values, for example:
String test = "this is test5";
String array[] = {"test1","test2","test3, test4,test5,test6,test7,test8"};
for(int i = 0;i < array.length; i++)
if (test.endsWith(array))
return array[i];
}The array that I am using holds closer to 15 values, but this loop can be hit thousands of times a day.  My  question is, are there any faster ways to loop through multiple strings than using arrays?  How do array lists or maps compare?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

sarcasteak wrote:
The array that I am using holds closer to 15 values, but this loop can be hit thousands of times a day. 15,000 comparisons a day is nothing. The following code does 15 million String compares in 188 ms.
public class StrCmp {
  public static void main(String... args) {
    String[] arr = {"abc", "sdfasdlfkjasldfjalsdkfj", "234l2kjala34kh", "slkfjal3490u saf",
                    "234lkjasldfhk23k4jhasf", "23l4kjsf", "alsflsdjkf", "aslkdfajsdf3h", "zzzzz",
                    "uhuhuhuhuh", "uhu2huh234234", "n234aoiuf", "234lasdhvoaih3", "zoziucvoiu", "asdflsjfl"};
    long start = System.currentTimeMillis ();
    for (int i = 0; i < 1000000; i++) {
      String str = "qqq";
      for (String str2 : arr) {
        if (str2.endsWith (str)) {
          System.out.println ("match");
    long end = System.currentTimeMillis ();
    System.out.println((end - start) + " millis");
My question is, are there any faster ways to loop through multiple strings than using arrays? How do array lists or maps compare?Before you worry about taking something simple that works and complicating it to make it faster, make sure there's a reason to do so.
If you do in fact need to make it faster, there are several different things you could do, but which one is best depends on a number of factors specific to your particular requirements and use cases.

Similar Messages

  • Simplest way to loop through a HashMap?

    Hi everyone,
    I'm a beginner at JSP, so please excuse my ignorance...
    I have a HashMap in which I need to loop through and print every "key" and associated "value".
    Doing research, I have come across multiple examples, but they all seem (to me) rather complex for something I think should be simple.
    Here is some code I have now. C_TITLE is a HashMap. My question is, is there an easier way to do this where I don't have to invoke a subclass? Or is this as simple and easy as it can get?
    Thanks!
    if (C_TITLE.size() > 0) { //only loop if there are items in this hashmap
         for (Iterator i=C_TITLE.entrySet().iterator(); i.hasNext(); ) {
                  Map.Entry mapentry = (Map.Entry) i.next();
              out.print (mapentry.getKey() + "|");
              out.print (mapentry.getValue() + "<BR>\n");
    }

      Iteratir iter = C_TITLE.keySet().iterator();
      while(iter.hasNext()) //or your for as well
          Object key = iter.next();
           Object value = C_TITLE.get(key);
      }With J2SDK 1.5 there is new for loop to iterate through collections.
    This will make Iterators almost unusable.

  • What is the best way to loop through TextFlow to find InlineGraphicElements?

    I have created a TextFlow and the images load fine, but I would like to loop through and update all the 'source' properties to change the images.  What is the best way to locate all the InlineGraphicElements in my TextFlow?
    Thanks!

    leaf = textflow.getFirstLeaf();
    while( (leaf = leaf.getNextLeaf()) != null)
    if(leaf is InlineGraphicElement)

  • Most efficient way to loop through similarly named fields?

    Hi,
    I have a 5 page document with each page containing appx. 50 similarly named fields.    E.g. Viol1Num, Viol2Num, Vio3Num ...  Viol50Num.
    I am looking for an efficient way of programming a loop to look at each field in Javascript so I can do some manipulations in those fields on what the user entered.
    In FormCalc I've previously used the 'foreach' function similar to:
    foreach (Field1, Field2, Field3.....Field50) do
         'BLAH'
    endfor
    however, that gets really lengthy, especially when dealing with subsequent pages where I have to start adding 'topmostSubform.Page2.' in front of each field name so that I can access from the first page all of the fields on subsequent pages.  Also, I need to do this in Javascript, not FormCalc.
    For example, in JS I am using this loop to mark all fields as read only:
    for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++) {
    var oFields = xfa.layout.pageContent(nPageCount, "field");
    var nNodesLength = oFields.length;
    for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {
    oFields.item(nNodeCount).access = "readOnly";
    How could I do something similar to that so I could look through each field and perform actions on it without having to list out every single field name?
    I tried altering that to look at fields instead of field properties, but I couldn't get it to run.
    Thanks.

    I have solved my issue.   It took some battling in javascript using xfa.resolveNode.
    I have 5 pages, each consisting of a series of 60 fields named Viol1Num, Viol2Num, Viol3Num .... Viol60Num.
    If when this javascript runs, it detects a blank field, then insert a '3' into it.
    The below is the javascript which runs for the second page of this document.
    while (LoopCounter < 61) {
    if ((LoopCounter != 21) && (LoopCounter != 22)) {
    if((xfa.resolveNode("topmostSubform.Page2.Viol" + LoopCounter + "Num").rawValue == null) | (xfa.resolveNode("topmostSubform.Page2.Viol" + LoopCounter + "Num").rawValue == "")) {
    xfa.resolveNode("topmostSubform.Page2.Viol" + LoopCounter + "Num").rawValue = 3;
    LoopCounter = LoopCounter + 1

  • Best way to loop through multiple rows to search for a count result

    I have a script where I'm trying to find a Rollup row without any children. I have created a SQL statement to do this, but I can only input one point at a time. If the count is greater than 0 then i'm good to go. If the count is 0 then I want to know about it.
    select count (*) from (Select * From ESSBASE_FCS.Ham
    where hier_pt like (Select substr(hier_pt, 1,8)||'%' as hcy_pt
    From ESSBASE_FCS.Ham
    Where Hier_Pt = '412375....')
    And Cctr_Or_Rollup 'Rollup')
    What is the best way to develop a SQL script that searches through all my Hier_pt's and return everything with a count of 0, instead of manually inputing each hier_pt at a time?
    Thanks for any help.

    Hi,
    Please read SQL and PL/SQL FAQ
    Please provide table structure, sample data and expected output.
    Additionally when you put some code please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    I noticed also that you have posted the same question here: {message:id=10678000}
    If you move your question to another forum please mark the previous question as answered.
    Regards.
    Al
    Edited by: Alberto Faenza on Nov 7, 2012 5:03 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Loop through a group of tables

    Someone who can help me with: I need to go a group of tables in a database, which have a common field. The idea is to do a select on that field in common according to a query criteria. thanks

    create table table1 as
    (select rid,identification,
            decode(identification,1,'Al',2,'Bo',3,'Che',4,'Doe',5,'Ed',6,'Fox',7,'Gil',8,'Hoss',9,'Ian',10,'Joe',11,'Ken',12,'Lou',13,'Moe',14,'Ned',15,'Oz',16,'Poe',17,'Red',18,'Sy',19,'Ted','Vic') name,
            Initcap(dbms_random.string('l',dbms_random.value(5,15))||' '||dbms_random.string('l',dbms_random.value(5,10))||' '||dbms_random.string('l',dbms_random.value(5,20))) info
       from (select level rid,
                    trunc(dbms_random.value(1,20)) identification
               from dual
             connect by level <= 10
    RID
    IDENTIFICATION
    NAME
    INFO
    1
    8
    Hoss
    Iqvispa Lmurse Zuzaozjmgruxk
    2
    5
    Ed
    Lomqevifqeeeo Nxlxnhdv Wlakstxjms
    3
    18
    Sy
    Znaked Eoenhxeeca Nrxpwjyt
    4
    14
    Ned
    Jbiebqxcowrw Ipuqfm Zlbjiumygtcnfgiq
    5
    16
    Poe
    Jmbwzhodm Ujcxeubr Ucikapudanbtyhrbla
    6
    11
    Ken
    Nwcdowlndfb Lzekz Fwmjhcufw
    7
    16
    Poe
    Ltiyuz Zuyevvf Ngeyowyyjvrh
    8
    2
    Bo
    Zrifwczbkktcouc Izpmaib Tmhkqatyahzuguwpw
    9
    6
    Fox
    Tsrghyzi Qdutdqqm Takrtwv
    10
    12
    Lou
    Zfgyftaidslpcg Osexqg Owaoafoipgn
    RID
    IDENTIFICATION
    NAME
    INFO
    1
    2
    Bo
    Agabtq Tanivdo Hiaybiuyyktitvwgjp
    2
    12
    Lou
    Znvcvycgllx Gtewsxz Lziuom
    3
    13
    Moe
    Qdzurj Cgdfmtslee Emtvhupylnalelbbacv
    4
    17
    Red
    Nwjjmqkfpxn Hiywfb Hrveoiegppo
    5
    1
    Al
    Bhnyjgnkmlsu Jbrdmiu Adwbpzbelyrebfq
    6
    11
    Ken
    Hsnccafffl Okfpeodw Znrmbrnxkxwi
    7
    8
    Hoss
    Olvwgjhtejhu Nvbofegy Kbanybopcg
    8
    1
    Al
    Cvnwwaw Hhzwsb Peuruso
    9
    19
    Ted
    Xuykzepjpdjrc Mmnxfdc Cdwfjvv
    10
    19
    Ted
    Zqmhv Mqxkio Mpbssxxurbxtaifud
    RID
    IDENTIFICATION
    NAME
    INFO
    1
    16
    Poe
    Gappv Ptkkgqh Zfbkoeb
    2
    3
    Che
    Ggbughdb Icdiwl Imtfng
    3
    9
    Ian
    Cadwemch Ckwdlrxs Kzdpanneushpp
    4
    7
    Gil
    Frlufjrk Amidybzd Rwlwqfxp
    5
    10
    Joe
    Rqvhbh Rbpdaklmsz Nhzkeblzmdgxvx
    6
    19
    Ted
    Sphkzeoean Epllenxz Cdpikiftoacwqrw
    7
    9
    Ian
    Ntovrotmwdaago Bpvdxmeofr Qfnpl
    8
    19
    Ted
    Sjookoa Ilotrpqyz Eaabfufbeeflb
    9
    17
    Red
    Pvzmbjepm Vevqae Oqnezylttqz
    10
    2
    Bo
    Rbjseracpal Exvukmsvt Auujopmdawrwzz
    RID
    IDENTIFICATION
    NAME
    INFO
    1
    12
    Lou
    Rmbjqggtwgvkuq Mgdxelhg Mcjsxldszzvsbnpex
    2
    15
    Oz
    Zdmfqyiqz Wrepkbn Jmvfrcwegqdxjeo
    3
    15
    Oz
    Klkzrjhvxo Xftxbac Ovhsvuvrvof
    4
    7
    Gil
    Pzktxz Kkopip Irfixa
    5
    17
    Red
    Hegcugpqxn Trdtcmkq Wljbm
    6
    1
    Al
    Pvlrqg Ceamqdxzh Mieubwiul
    7
    5
    Ed
    Uejsqrghek Yrqjfkjy Itnwowljg
    8
    13
    Moe
    Llguurt Hiqfycrkel Pcftjjbvbwimsqqlt
    9
    7
    Gil
    Hnsaeflly Arbml Ovmcwrzfqyy
    10
    2
    Bo
    Hmzxxlzvoqskjsx Itandsik Pxlqcdnxkv
    RID
    IDENTIFICATION
    NAME
    INFO
    1
    8
    Hoss
    Oogcgbjsmmqm Vxpknalu Hbxfvydnfdnqz
    2
    1
    Al
    Xaejofaeramguil Rtmtcbkpp Adpmrsytubflyfhoda
    3
    3
    Che
    Weyphtako Xendsrx Uhhatkyzhptgkg
    4
    15
    Oz
    Lhwpxgfvyh Xdvvcv Bxtueffbzkri
    5
    1
    Al
    Mjtpycls Myxftbcb Edbytrjwzppfdkqyn
    6
    2
    Bo
    Gujxzuzogigwdo Htzvfsfnh Cekmyezwlyuzcp
    7
    4

  • CRXI: Formula To Loop Through Formulas in Group

    Post Author: Mile
    CA Forum: Formula
    I have a hierarchy of groups allowing the drilldown of data. Due to a flaw in database design, there is no real join between two tables and I've improvised as best I can. The problem is that on one of my items, there can be as many as thirteen products attributed to it. This produces thirteen records for the one item, meaning that summing on the amount field will be thirteen times the actual amount. But, as I said, each product may have a different number of products attributed to it, meaning it could be five times the amount, seven times, the amount, etc.
    I've been able to make a summary at the item level whereby all I need to do is a formula that divides the sum by the count of products to get the actual value. When I move to the next group level up, I find that it can't mathematically be done to divide the summed amount because one item in the group may have two products (therefore two records) and another ten products.
    What I'm wondering is whether there is a way, using a formula, that can loop through all the items in a group and add the summary field.
    i.e.
    ITEM1 - PROD1 - $5
    ITEM1 - PROD2 - $5
    ITEM2 - PROD1 - $7
    ITEM2 - PROD2 - $7
    ITEM2 - PROD3 - $7
    ITEM2 - PROD4 - $7
    ITEM2 - PROD5 - $7
    ITEM1 would summarise to $5, once I've divided it by two. ITEM2 would summarise to $7, once I've divided it by five.
    So, ideally, I would loop through a group above the item level, adding the summaries, ending with $12.
    Can this be done?

    Post Author: synapsevampire
    CA Forum: Formula
    Your difficulty is termed record or row inflation.
    If you want a summary at the group level, group by the item field and use a maximum instead of a sum.
    maximum({table.value},{table.item})
    Then to get a grand total, create a formula such as the following for the gropup footer:
    whileprintingrecords;numbervar MyTotal;MyTotal := MyTotal + {table.value}
    Now you can display the grand total in a subsequent secion using:
    whileprintingrecords;numbervar MyTotal
    -k

  • Loop through a csv file and return the number of rows in it?

    What would be simplest way to loop through a csv file and
    return the number of rows in it?
    <cffile action="read" file="#filename#" output="#csvstr#"
    >
    <LOOP THROUGH AND COUNT ROWS>

    ListLen(). Use chr(13) as your delimiter

  • Dbma_scheduler job executing procedure that loops through all client schemas in the database rolls back transaction incase of exception

    Hi,
    Needed your inputs on approach to implement a job using dbms_scheduler.
    We have around 2000 schemas. Each schema has a package with 2 procedures.
    The requirement is to create a single job in SYS that would loop through each schema and run the procedures at a specific time ( once a day) and send email notification on success or failure.
    Job script:
    BEGIN
        dbms_scheduler.create_job( job_name=> 'LOAD_EACH_SCHEMA_AUDIT_DATA',
                                   job_type=>'PLSQL_BLOCK',
                                   job_action=>'BEGIN  sys.p_loadaudit;     
                                    END;',
                                   start_date=>systimestamp,
                                   repeat_interval=>'FREQ=MINUTELY;INTERVAL=1',
                                   number_of_arguments=>0,
                                   enabled=> true,
                                   comments=>'Job repeat interval is every 5 mins' );
                                   END;
    Note: for testing purpose i have set repeat interval to minutely.
    Procedure job will be executing:
    Procedure sys.p_loadaudit:
    CREATE OR REPLACE
    PROCEDURE p_loadaudit
    AS
        v_count          NUMBER:= 0;
        lv_error_message VARCHAR2(4000);
        vstmt            VARCHAR2(4000);
    BEGIN
        FOR i IN
        ( SELECT username FROM dba_users WHERE username LIKE 'ABCFIRM%'
        LOOP
            vstmt:= 'begin ' || i.username || '.pkg_audit_info.p_load_coa; end;';
            EXECUTE immediate vstmt;
            vstmt:= 'begin ' || i.username || '.pkg_audit_info.p_load_am; end;';
            EXECUTE immediate vstmt;
        END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
        lv_error_message := 'Error in procedure p_loadaudit: ' || SQLCODE || ' -ERROR- ' || SUBSTR(
        sqlerrm,1,300) || '*' || dbms_utility.format_error_backtrace;
        raise_application_error(-20002,lv_error_message);
    END p_loadaudit;
    Example of one schema: SCHEMA_01
    create or replace
    PACKAGE pkg_audit_info
    AS
    type cursortype
    IS
        ref
        CURSOR;
            PROCEDURE p_load_COA;
            PROCEDURE p_load_AM;
       END pkg_audit_info;
    create or replace
    PACKAGE body pkg_audit_info
    AS
    PROCEDURE p_load_COA
    AS
    BEGIN
    INSERT INTO TABLE1();
    EXCEPTION
    WHEN OTHERS THEN
        lv_error_message := 'Error in procedure pkg_audit_info.p_load_COA: ' || SQLCODE
        || ' -ERROR- ' || SUBSTR(SQLERRM,1,300) || '*' || dbms_utility.format_error_backtrace;
        RAISE_application_error(-20002,lv_error_message);
    END p_load_COA;
    PROCEDURE p_load_AM
    AS
    BEGIN
    INSERT INTO TABLE2();
    EXCEPTION
    WHEN OTHERS THEN
        lv_error_message := 'Error in procedure pkg_audit_info.p_load_AM: ' || SQLCODE ||
        ' -ERROR- ' || SUBSTR(SQLERRM,1,300) || '*' || dbms_utility.format_error_backtrace;
        RAISE_application_error(-20002,lv_error_message);
    END p_load_AM;
    END pkg_audit_info;
    Table1 and table1 exist in schema_01.
    All 2000 schemas have same package.procedures.
    Due to security reasons i have removed the actual code.
    I was able to execute the job successfully. However, when a schema procedure (SCHEMA_01.pkg_audit_info.p_load_COA) throws an exception, the job fails and all transaction is rolled back.
    Is there a way to loop through each schema and execute the related procedures. Even if exception happens, it should rollback only for that schema and continue the other schemas in the loop?
    Please let me know if there is a better way to achieve this. Is the way i am handling exceptions in the job/procedure correct?
    Thanks

    Hi,
    RAISE_APPLICATION_ERROR will cause the program to exit back to the caller, even if you place it in a block within the loop, so the RAISE or RAISE_APPLICATION_ERROR instruction should be placed in your "pkg_audit_info.p_load_AM" and "pkg_audit_info.p_load_coa" procedures. This way, you can use a block inside the loop and log the error.
    FOR i IN
        ( SELECT username FROM dba_users WHERE username LIKE 'ABCFIRM%'
        LOOP
           BEGIN
            vstmt:= 'begin ' || i.username || '.pkg_audit_info.p_load_coa; end;';
            EXECUTE immediate vstmt;
            vstmt:= 'begin ' || i.username || '.pkg_audit_info.p_load_am; end;';
            EXECUTE immediate vstmt;
    EXCEPTION
    WHEN OTHERS THEN  
        --> Log the error in a custom log table otherwise you will not know what happened for that schema: don't forget the username
    END;
    END LOOP;

  • Loop through tree node children recursively

    Is there an easy way of looping through all the child nodes of a MutableTreeNode and the children of those children if they have any?
    Thanks

    With a recursive function (this is depth first):
    public void traverse(Node node) {
      // do something with node
      for(Node child : node.getChildren()) {
        traverse(child);
    }You could also look at depthFirst/breathFirst/preorder/postorderEnumeration() methods on DefaultMutableTreeNode if that's what you actually got.

  • Loop through all items in all data blocks?

    Is there a way to loop through every item in every data block and set the property of a format mask?

    I do not know what error it is, only that an on-error trigger fires.
    I found out one thing I was definitely doing wrong, using nextblock, nextitem properties at the wrong level.
    DECLARE
         v_firstblock VARCHAR2(50);
         v_currentblock VARCHAR2(50);
         v_firstitem VARCHAR2(50);
         v_currentitem VARCHAR2(50);
         v_counter NUMBER :=0;
         v_counter2 NUMBER :=0;
    begin
       v_firstblock := get_form_property(:System.Current_Form,first_block);
       v_currentblock:= get_block_property(v_firstblock,nextblock);
       MESSAGE(v_firstblock||v_currentblock);
         LOOP
              v_counter := v_counter +1;
              IF (v_counter >10) THEN
                   exit;
              END IF;
              IF (v_currentblock = v_firstblock) THEN
                             exit;
           ELSE
                   v_firstitem :=  get_block_property(v_firstblock,first_item);
                        IF (lower(GET_ITEM_PROPERTY(v_firstitem,format_mask))=lower('mm-dd-yyyy')) THEN
                                       SET_ITEM_PROPERTY(v_firstitem,format_mask,'DD-MON-YYYY');
                        END IF;
                   v_currentitem :=  get_block_property(v_firstblock,first_item);
                   v_currentblock:= get_block_property(v_currentblock,nextblock);
                   GO_BLOCK(v_currentblock);
                        LOOP
                             v_counter2 := v_counter2 +1;
                             IF (v_counter2>15) THEN
                                  exit;
                             END IF;
                             v_currentitem:= get_item_property(v_currentitem,nextitem);
                             MESSAGE(v_counter||v_firstblock||v_currentblock||v_firstitem||v_currentitem||v_counter2);
                             IF (v_currentitem <> v_firstitem) THEN
                                  IF (lower(GET_ITEM_PROPERTY(v_currentitem,format_mask))=lower('mm-dd-yyyy')) THEN
                                       SET_ITEM_PROPERTY(v_currentitem,format_mask,'DD-MON-YYYY');
                                  END IF;
                             ELSE
                                  exit;
                             END IF;
                        END LOOP;
               END IF;
      END LOOP;
         end;Here is updated new code. I am currently trying to debug it, it has crashed my form on the server when tied to a button press.
    EDIT: So far I have found that it infinitely loops through the first 3 items and a null item in the first block. Still looking into why...
    EDIT: Some code changes to temporarily stop infinite loop and make v_currentblock actually change. Still loops through same 3 items in the first data block even though v_currentblock changes.
    Edited by: 878576 on Oct 21, 2011 12:46 PM

  • Looping through array

    If I declare an array such as the one below.
    declare
    type array_type is table of varchar2(100) index by binary_integer;
    component_array array_type;
    begin
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      for i in component_array.FIRST .. component_array.LAST
      loop
        dbms_output.put_line(component_array(i));
      end loop;
    end;Is there a way to loop through only the existing binary_integer indeces? For example, if you execute the block above, you'll get an error because the loop iteration is hitting 12346 which of course doesn't exist. Other than the workaround below, is there another way using any type of array method?
    declare
    type array_type is table of varchar2(100) index by binary_integer;
    component_array array_type;
    begin
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      for i in component_array.FIRST .. component_array.LAST
      loop
        begin
          dbms_output.put_line(component_array(i));
        exception
          when NO_DATA_FOUND then
            null;
        end;
      end loop;
    end;
    Thanks.

    Hi,
    Not to hijack this thread, but, since this is related to my answering OP's question, I am posting here.
    How come this code is erroring out?
    DECLARE
      TYPE array_type IS TABLE OF VARCHAR2(100) INDEX BY VARCHAR2(1000);
      component_array array_type;
    BEGIN
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      FOR i IN component_array.first .. component_array.last LOOP
        IF component_array.exists(12345) THEN
          dbms_output.put_line(component_array(i));
        END IF;
      END LOOP;
    END;errors out with no_data_found, but, this doesn't ?
    DECLARE
      TYPE array_type IS TABLE OF VARCHAR2(100) INDEX BY VARCHAR2(1000);
      component_array array_type;
    BEGIN
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      FOR i IN component_array.first .. component_array.last LOOP
        IF component_array.exists(12344) THEN
          dbms_output.put_line(component_array(i));
        END IF;
      END LOOP;
    END;notice the static numbers in the .exists parameter....

  • Looping through lines in a jtextpane...?

    Anyone know a smooth clean way to loop through the lines in a jtextpane? (in the document).
    I need each line as String to do some checks on them...
    Any help would be appreciated.

    I am doing something like:
    Element map = doc.getDefaultRootElement();
    int n = map.getElementCount();
    for(int i=n; n >= 0; i--){
         Element e = map.getElement(i);
         // Now turn this element into a string.
         try{
              String line = doc.getText(e.getStartOffset(), e.getEndOffset()-e.getStartOffset());
         }catch(BadLocationException ble){
              System.out.println("Error in findTabWord()!");
    }But interested in if there are any better (faster) ways of doing it.

  • How to loop through dates using For Loop?

    Hi All,
    I assume the For Loop is the best way to loop through days in a date range, but I can't figure out how to add a day in the "AssignExpression" box.  The following gets the errors "The expression contains unrecognized token 'DAY'",
    and "Attempt to parse the expression 'DATEADD(DAY, 1, @CounterPlayer)' failed and returned error code 0xC00470A4."
    InitExpression: @CounterPlayer = @DownloadFileDatePlayer
    EvalExpression: @CounterPlayer <= @Today
    AssignExpression: @CounterPlayer = DATEADD(DAY, 1, @CounterPlayer)
    I need to step through days, not through files.  What am I doing wrong here?  I changed "DAY" to "Day," but that didn't fix it.
    Thanks,
    Eric

    DOH!  It just needed properly placed quotes.  Here's the answer:
    AssignExpression: @CounterPlayer = DATEADD("DAY", 1, @CounterPlayer)

  • How to loop through columns of a table?

    Hi, guys
    Is there a way to loop through each column of a table? If there is a way, then how?
    I have a table with columns of different datatypes , and I want to set default values for each column with a loop but don't know how to make it happen.
    For example,
    Table: Employees
    declare
      rec  Employees%ROWTYPE;
    begin
      for col in rec.empno .. rec.location loop
         if col = rec.empno then -- set default value for column empno;
      end loop;
    end;
    /Sorry, I am a newbie to PL/SQL. Please help!
    Thanks in advance.
    Edited by: HappyJay on 2010/05/11 10:36

    Hi,
    You can query the data dictionary views all_tab_columns (or user_tab_columns) to get the names of all the columns in a particular table.
    Here's an easy way (but not a very efficient way) to loop through them:
    SET     SERVEROUTPUT     ON
    BEGIN
         FOR  c IN ( SELECT  column_name
                         FROM    all_tab_columns
                  WHERE   owner     = 'SCOTT'     -- Remember ot use UPPER CASE inside quotes
                  AND         table_name     = 'EMP'
         LOOP
              dbms_output.put_line (c.column_name || ' = column_name inside loop');
         END LOOP;
    END;
    /I'm confused about what you want to do, though.
    Do you want the PL/SQL code to write and/or execute an ALTER TABLE command for each column?

Maybe you are looking for

  • How can i do if I changed of computer and mi iPhone was sinced there and I don't want to lose it all

    Mi iPhone was sinced with my old Mackbook pro and now I have another Mac and when I try to zinc it with the new Mac I think it erase it all so what can I do for not lose it all ? (I will never zinc mi iPhone  with the old computer)

  • Transferring photo stream from iPhone 4 to 4s

    I just switched from an iPhone 4 to a 4s. I made sure that my recent photos were backed up in photo stream but not on my computer before I did this. Is there anyway to access those photos from my new iPhone? They are not showing up in my new photo st

  • Detailed example for ABAP mapping in XI7.0 with code in  class builder

    hi experts,               will any one one send me the detailed example(including navigation steps) for ABAP mapping in XI7.0 with code in class builder.                                                      Thankin u,

  • Help on Business Scenario Configuration Guide for SRM Server 5.5

    hai friends where can i get Business Scenario Configuration Guide.for Version SRM server 5.5 i found for 4.0 and 5.0 but not for 5.5 Please let me know the link of market place thanks Regards Krishna

  • Safari Not Displaying .txt

    Hey, everyone - Back before I upgraded to Leopard (and Safari 3), whenever I would come across a .txt file online, it would display in the Safari window. This made for a rather handy text reader, and I found it convenient. Now, however, whenever a .t