Count occurrences of a phrase

Hi, what is the best way to count occurrences of a phrase (multi-gram words) in a document (corpus)?
I am using String.split("regular expression here") to split the content of a document. For example to count how many times "this noun phrase" occurs in a document, i do
String nounSingular = "this noun phrase";
String nounPlural = "this noun phrases";
String documentContent="blahblah...";
int occur = documentContent.split("\\b+"+nounSingluar+"\\b+").length;
......But my worry is that regex processing is heavy. So the scalability of this method may be bad over large corpus, and long noun phrase strings.
Any better ideas please? Using String.indexOf() iteratively?
Many thanks!

hey
so if you use either split, or stringtokenizer, you will not get the correct result. you must use indexOf.
Why? if you use split and the phrase is at the very start of the string, then you will not get the correct number of occurrences.
Heres some code that works on a string. can't say much for performance! maybe read your text in line by line..?
          String searchMe = "policy policy bananas is the policy base of all policy";
          int occurs = 0;
          int nextIndex = 0;
          while (true){
               int test = searchMe.indexOf("policy", nextIndex);
               if (test == -1){
                    //then there are no occurrences
                    break;
               } else {
                    //there is an occurrence
                    occurs++;
                    nextIndex = test + 1;
          }try it with split, it doesn't work... go ahead!
Oh, and my message to the guy who has a go at me for reviving an old thread: People SEARCH and get these threads all the time in Google results. THATS WHY i post. just trying to help everyone...

Similar Messages

  • Count occurrences of matched words

    All,
    Does anyone know the syntax or algorithm to count the occurrences of matched words that where compared from two separate columns or tables? Below is a simple example of the type of comparison I would like to perform. I found the function regexp_count, but it only works in 11g. Unfortunately, I have Oracle 10g. Any help would be greatly appreciated. Thanks
    i.e.
    drop table compare_matched_words;
    create table compare_matched_words (
    query_id number,
    query_string1 varchar2(80),
    query_string2 varchar2(80)
    insert into compare_matched_words values (1, 'oracle 255','oracle1 255');
    insert into compare_matched_words values (2, 'larry or ellison','larry or');
    insert into compare_matched_words values (3, 'oracle and text','and');
    insert into compare_matched_words values (4, 'market1 share','market share');
    insert into compare_matched_words values (5, 'larry or',' larry or ellison');
    insert into compare_matched_words values (6, 'oracle1 255','oracle 255');

    Issue is not in 11g. Before you can solve the task you need to split QUERY_STRING1 and QUERY_STRING2 into words and then compare words for same QUERY_ID. To split string into words use something like:
    select  query_id,
            regexp_substr(query_string1,'\w+',1,column_value) query_string1_word
      from  compare_matched_words t,
            table(
                  cast(
                       multiset(
                                select  level
                                  from  dual
                                  connect by level <= length(regexp_replace(regexp_replace(QUERY_STRING1,'\w+','A'),'[^A]'))
                               ) as sys.OdciNumberList
    SQL> /
               QUERY_ID QUERY_STRING1_WORD
                      1 oracle
                      1 255
                      2 larry
                      2 or
                      2 ellison
                      3 oracle
                      3 and
                      3 text
                      4 market1
                      4 share
                      5 larry
               QUERY_ID QUERY_STRING1_WORD
                      5 or
                      6 oracle1
                      6 255
    14 rows selected.
    SQL> Now:
    select  t1.query_id,
            t1.query_string1,
            t2.query_string2,
            count(*) matchin_word_count
      from  (
             select  query_id,
                     query_string1,
                     regexp_substr(query_string1,'\w+',1,column_value) query_string1_word
               from  compare_matched_words t,
                     table(
                           cast(
                                multiset(
                                         select  level
                                            from  dual
                                           connect by level <= length(regexp_replace(regexp_replace(query_string1,'\w+','A'),'[^A]'))
                                        ) as sys.OdciNumberList
            ) t1,
             select  query_id,
                     query_string2,
                     regexp_substr(query_string2,'\w+',1,column_value) query_string2_word
               from  compare_matched_words t,
                     table(
                           cast(
                                multiset(
                                         select  level
                                            from  dual
                                           connect by level <= length(regexp_replace(regexp_replace(query_string2,'\w+','A'),'[^A]'))
                                        ) as sys.OdciNumberList
            ) t2
      where t2.query_id = t1.query_id
        and t2.query_string2_word = t1.query_string1_word
      group by t1.query_id,
               t1.query_string1,
               t2.query_string2
      order by t1.query_id
               QUERY_ID QUERY_STRING1                  QUERY_STRING2                   MATCHIN_WORD_COUNT
                      1 oracle 255                     oracle1 255                                      1
                      2 larry or ellison               larry or                                         2
                      3 oracle and text                and                                              1
                      4 market1 share                  market share                                     1
                      5 larry or                        larry or ellison                                2
                      6 oracle1 255                    oracle 255                                       1
    6 rows selected.
    SQL> SY.

  • Count Occurrences of String in Cell Range

    I have a column like this:
    Header 1
    AA
    AA, BB
    BB
    BB, AA
    AA
    I need to count how many times "AA" appears throughout this column, so in this case the answer should be 4. I've tried searching for hours, but can't find anything. Anyone have any ideas?
    Thanks!

    Hi G,
    COUNTIF, using wildcards can count the number of cells containing the specific string.
    The example below shows the results where a cell contains AA more than once. C2 contains the same formula as above. C4 contains =SUM(B). Cells in column B use LEN() and SUBSTITUTE to calculate the number of times AA appears in each row of column A.
    A2, and filled down: =(LEN(A2)-LEN(SUBSTITUTE(A2,B$1,"")))/LEN(B$1)
    Regards,
    Barry

  • Selected text highlights & counts occurrences

    After upgrading to FF 6.0.2 I've noticed that whenever I highlight text on a page a little window/box pops up in my lower left corner saying "Number of occurrences: 10" or whatever the number of instances might be for that word. All the occurrences are highlighted as well.
    How can I remove this little window/box/popup? To what feature is it connected so I can change preferences? I have been thus far unsuccessful in my attempts to close the box and my detective skills are sorely lacking since I have not been able to find the source on my own.

    Not a standard feature in Firefox. http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes

  • How to count occurrences on dates

    I have a table which which measures the occurrences of various events, and I'm trying to figure out a way to calculate the occurrences on each day.
    Table 1 - Occurrences
    3/4/08 4:40 PM
    3/4/08 9:45 PM
    3/5/08 2:50 AM
    3/5/08 5:45 AM
    3/5/08 9:30 AM
    3/5/08 12:30 PM
    Table 2 - Occurrences per day
    3/4/08 - 2
    3/5/08 - 4
    Is there a way to get Numbers to do a COUNTIF and recognize ONLY the date (and not the time) for Table 2?

    Hello
    Assuming that the original occurences are stored in column A, in column B put the formula
    =DATE(YEAR(A),MONTH(A),DAY(A))
    so you will have stripped date.
    Now in Table 2 you may use:
    =COUNTIF(Table 1 :: B,DATE(2008,3,4)) --> 2
    =COUNTIF(Table 1 :: B,DATE(2008,3,5)) --> 4
    Or, for an easier use
    in Table 2
    column A
    3/1/2008
    3/2/2008
    3/3/2008
    3/4/2008
    3/5/2008
    column B
    =IF(COUNTIF(Tableau 1 :: B,A),COUNTIF(Tableau 1 :: B,A),"")
    Yvan KOENIG (from FRANCE vendredi 2 mai 2008 09:08:54)

  • Counting rows with multiple criteria

    I know this is a silly beginner question, but is there an easy way to count the number of rows in a table which match criteria based on different columns (sort of a countif with multiple criteria). For example, if Column A in a table has "All, Some, None" responses and Column B has "Main, Off" responses, is there an easy way to count the number of rows in which Column A has All and Column B has Off?

    Neondiet wrote:
    From an intellectual and philosophical view I agree with you. But from a practical view what I really want to do is just use one application for my spreadsheet tasks, not jump back and forth because one sheet I share with MS Windows users, and another with Numbers users, and another with OS X users who don't have Numbers or Excel but do have NeoOffice. Maybe I have to settle for that though.
    Yeah... this kind of situation stinks. Its like needing to writing software that will run on both Macs and PCs.
    Anyway, I've followed the advise in this forum and resorted to using a hidden column with concatenated values to solve my own problem, though it does seem like a bit of a hack compared to managing a single formula in a single cell. Horses for courses I suppose.
    jaxjason has posted a very elegant pivot table like solution that utilizes this technique. See http://www.numberstemplates.com/forums/showthread.php?t=36
    Btw, from what I've read on the net to date, SUM (in Excel) with an array formula answers the original authors problem of counting occurrences of values, not SUMPRODUCT; which I believe sums up the contents of cells in a range, if cells in other ranges match specific criteria.
    Yes, if you use the '*' (as indicated above) then SUM() is sufficient though SUMPRODUCT() will work as it degenerates to SUM when there is only one argument. If you use two arrays as arguments (like: = SUMPRODUCT((A1:A4="All"), (B1:B4="Off")), then SUMPRODUCT() is necessary. Here's my understanding of how it works (I hope your able to follow my abuse of algebraic techniques):
    =SUM((A1:A4="All") * (B1:B4="Off"))
    expanding the array expressions...
    =SUM((A1="All", A2="All", A3="All", A4="All") * (B1="Off", B2="Off", B3="Off", B4="Off"))
    at this point Excel computes the equality expressions, for example...
    =SUM((TRUE, FALSE, TRUE, FALSE) * (TRUE, TRUE, FALSE, FALSE))
    expanding the array multiplication...
    =SUM((TRUE * TRUE, FALSE * TRUE, TRUE * FALSE, FALSE * FALSE))
    Excel, apparently, then, when forced to multiply Boolean values, maps TRUE -> 1 and FALSE -> 0...
    =SUM((1 * 1, 0 * 1, 1 * 0, 0 * 0))
    performing the multiplications...
    =SUM((1, 0, 0, 0))
    summing...
    =1 + 0 + 0 + 0
    resulting...
    =1
    I'm afraid, now, if I continue any further, Yvan will chastise me.

  • Error 21470247770 when attempting to run macros in Project Server v2010

    We have some new users to our Project Server that are getting the following error when they attempt to run our macros which are stored on the Enterprise Global:
    "System Error &H8007007E (-2147024770).  The specified module could not be found."
    We have already tried resetting their Global.mpt as well as checking for duplicate copies of the macros in their local Global.mpt, to no avail.  This sounds like the system is preventing them access to the modules.  Thoughts?
    Chris

    01:51.197: INFO:    Setup exit code: 0x00009C47 (40007) - Required updates failed to download.
    This is why I suggest people run ProcMon filtering with Operation Is WriteFile and then using Count occurrences... on Path to at least find out what all their diagnostics might be.  However, even if there aren't any other diagnostics than this at least
    ProcMon's other trace events will supplement the meaning of whatever you do see.  E.g. provided you can infer a match of any one WriteFile event to a particular log record you can hopefully use preceding File and Registry access events as if they had
    something to do with the generation of that message.
    BTW I notice that you were essentially up-to-date in your maintenance for the version of IE that you were switching from.  What would you say to someone who was trying to do what you are doing who was also saying that they weren't connected to the Internet
    so therefore they didn't see any need to do any maintenance?  Would the procedure you found help them too?
    C.f.
    http://answers.microsoft.com/en-us/ie/forum/ie9-windows_7/ie9-wont-install/8f6a724c-4fff-43fb-9cf4-bb2f13fc6144?page=2
    Anyway I hadn't thought of using the IEAK as a method of doing this so I'm pointing that thread here for that possibility.
    Thanks for the tip.
    Robert Aldwinckle

  • Internet Explorer cannot open url in local Windows network share

    Windows Server 2012 R2 as a domain controller
    Internet Explorer 11 64/32
    Favorites are redirected to a Windows network share (on the server itself)
    Issue: When clicking a favourite redirected to the Windows network share, IE does nothing. 
    For testing purpose,
    I double click a .url file in redirected Favorites (e.g.
    \\domain_controller\profiles\username\Favorites\website.url), IE opens with a blank page. 
    If the .url file is placed at local drive or a Samba share (e.g. in a Synology box, probably it does not really matter as long as it is a network share residing in another computer), IE works fine.
    The issue applies to every one (probably except Administrator) logged on the domain controller.
    I tried reset IE.  It did not work.
    Favourites redirection works on Windows 8.1 client computers in the domain.
    Pinned Site Shortcut (.website) file works everywhere
    When Enable Protected Mode in Internet Options\Security\Internet is disabled, IE can open .url file in a Windows network share.  But it is probably not a good idea to permanently disable it.
    Any suggestion on fixing the issue?  Thank you.

    tried ProcMon, the events captured are enormous even after I filtered out those I am sure do not matter.  It was hard to spot what went wrong if I don't know what to look for. 
    Which is why I made the suggestion to filter coarsely and wait for a divergence in your two nearly equivalent traces.   <eg>
    Otherwise, if you are only looking at one trace but think that there is a possibility that some diagnostics may have been written, filtering with 
    Operation Is WriteFile  is often very handy.  With that filter you can also use the Count occurrences... tool for the number of distinct  Path  values which were involved.
    In fact, now that I have reviewed the symptom description, filtering coarsely might also mean using only the File Access events and filtering with  Path Contains Fav   Do that with each of your traces and see where there is a divergence. 
    Then turn the filter off at that point or perhaps just add Registry events at that point (e.g. use the button but leave your filter for  Path in place).  Etc.
    Good luck
    Robert Aldwinckle

  • Radio buttons that pass a value to a textfield

    Hi everybody;
    I’m trying to create a “Rating Matrix” for the evaluation of new raw material. On this form I create a group of radio buttons (i.e. Radio1 to Radio5).
    Each radio represents a rating value “Poor=1, Fair=3, Average=5, Good=7, Excellent=9” and I would like to capture this rating (1 or 3 or 5, etc) into a Texfield.
    I work in solving this issue without success, if any of you have any example that I could look at it, I will really appreciate.
    Thanks in advance.

    Thanks for your fast response! WowWhat I'm trying to do, is being able to pass a value to a TextField depending on the ratio button selected.If I choose one of the ratio buttons of the group "Opacity" (Opacity1, Opacity2, Opacity3, Opacity4 or Opacity5), I like the TextField "Rank" to show the value.If Opacity1 selected, Rank field value = 1.If Opacity2 selected, Rank field value = 3.If Opacity3 selected, Rank field value = 5.If Opacity4 selected, Rank field value = 7.If Opacity5 selected, Rank field value = 9.
    You think this can work?
    if(Opacity1.value == "On") {Rank.value==1; // value is added to the texfield;}
    if(Opacity2.value == "On") {Rank.value==3; // value is added to the texfield;} Else if(Opacity3.value == "On") {Rank.value==5; // value is added to the texfield;}
    Sorry not a programmer.I understand the loop, but is not very clear where I need to add this script, on the radio or in the textfield?Thanks.
    Date: Thu, 18 Jul 2013 11:48:28 -0700
    From: [email protected]
    To: [email protected]
    Subject: Radio buttons that pass a value to a textfield
        Re: Radio buttons that pass a value to a textfield
        created by GKaiseril in JavaScript - View the full discussion
    Do you want to count the occurrence of each value and report that in a given text field?
    Do you understand that when no radio button or check box when not selected has a value of the string "Off".
    Assuming that the value for various radio buttons in a group is the value you want to test
    // custom calculation script;
    // count occurrences of "9" values
    var nTest = 9; // value to test for;
    var nCount = 0; // count of occurrences;
    // loop through the fields;
    for(i = 1; i < 6; i++) {
    var nValue = this.getField("Radio" + i).value;
    // test if field value equals test value;
    if(nTest == nValue) {
    nCount++; // values equal so increment count;
    } // end test of field value
    } // end field name loop;
    event.value = nCount; // set field value;
    // end custom calculation script;
         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/5518047#5518047
         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/5518047#5518047
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5518047#5518047. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in JavaScript 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.

  • Autosync a folder with PDF for iPad/iPhone

    Is there a way to autosync a folder with iPad?
    We'll have a shared PDF folder in our company, and what we need is the iPad to autosync with that folder, because the PDF files can change from day to day. So far we have to choose the specific file on the iPad and delete it, and then again choose the new file, which has been updatet, that's a bit difficualt. The problem is that we are not online with the iPads, and its not possible to be so. So using DropBox or similiar is not possible.
    This solution is possible with music, cant understand why is not possible with PDF. Our PDF's are in different folder, so we need a app/solution which makes is possible to choose folders, and not files.
    Hope some can help me:-)

    Spotlight can certainly search pdf files I make. For instance, I have a file I created a couple of days ago named "AlaskaAirXmas06.pdf" and if I enter the search term "Horizon Air" that file is the top pick in Spotlight. When I select that file to open from the Spotlight results list, it opens in Preview with the first instance of "Horizon Air" highlighted, and with the drawer open listing all 5 occurrences of the phrase in the pdf. I have a file named "hanover.pdf" which I downloaded off the British Royals' web site, and when I do a search in Spotlight for the word "brunswick" that pdf pops up as the top search result, opening it has the word highlighted. So normal text based pdfs that can be opened by Preview and were created using my Mac are certainly indexed and searchable by Spotlight. The hanover.pdf file was created by QuarkXPress and encoded by Acrobat PDFWriter for Mac. I also have a file that is searched just fine by Spotlight that was also downloaded from the Royals' web site, and it was created on a Windows machine using MS Word and encoded using Acrobat Distiller for Windows.
    However, I have in fact opened all the above at one time. Whether that will make a difference or not I don't know. I can search other pdfs from a Mac that I know I have not actually opened. Whether that would be true of pdfs not opened and not created by a Mac I don't know.
    You might check your machine to make sure you have this:
    "/System/Library/Spotlight/PDF.mdimporter"
    That is necessary for Spotlight to be able to parse pdf files. If you have the importer and have tried re-indexing the folder containing the pdfs, more information about the pdf files themselves might help determine the source of your problem.
    Francine
    Francine
    Schwieder

  • Searching algorithm

    Hello World!
    I'm trying to build a program that will count the occurrences of words in a text file.
    I need to find a specific word in a text file, and count how many times it occurs.
    can anybody help me on this? whole algorithm is perfect, but a little ideas are awesome too!

    I'm trying to build a program that will count the occurrences of words
    in a text file. I need to find a specific word in a text file, and count how
    many times it occurs.Which do you need to do: count occurrences of all words or count how many times a single predetermined word occurs?
    If the latter, what do you mean by "word"? Does the sentence "hello world!" contain the word "hell"? How about "world", "world!", or both?

  • Field encryption

    Does anyone know what I need to do to encrypt the values for a particular field in a table?, rather than using views/roles or fine-grained access control,
    thanks.

    I used the following functions to encode, respectively decode sonething.
    Function n_code ( V$S in varchar2 ) RETURN varchar2
    IS
    phrase varchar2(10):='Your Key Phrase'; -- CONSTANT
    s1 varchar2(1);
    s2 varchar2(1);
    x number;
    y number;
    V_Temp varchar2(10):='';
    BEGIN
    for count in 1..length(V$S) loop
    s1:=substr(V$S,count,1);
    s2:=substr(Phrase,count,1);
    x:=ascii(s1);
    y:=ascii(s2);
    x:=mod(x+y,256);
    s1:=chr(x);
    V_Temp:=concat(V_Temp,s1);
    --dbms_output.put_line(s1);
    end loop;
    -- dbms_output.put_line(retur);
    RETURN V_Temp;
    EXCEPTION WHEN OTHERS THEN RETURN NULL;
    END;
    Function d_code ( V$S in varchar2 ) RETURN varchar2
    IS
    phrase varchar2(10):='Your Key Phrase'; -- CONSTANT !!!
    s1 varchar2(1);
    s2 varchar2(1);
    x number;
    y number;
    V_Temp varchar2(10):='';
    BEGIN
    for count in 1..length(V$S) loop
    s1:=substr(V$S,count,1);
    s2:=substr(phrase,count,1);
    x:=ascii(s1);
    y:=ascii(s2);
    x:=x-y;
    if x<0 then
    x:=x+256;
    end if;
    s1:=chr(x);
    V_Temp:=concat(V_Temp,s1);
    --dbms_output.put_line(s1);
    end loop;
    If the string that is to be encoded is longer than the key phrase, you mai decompose it in groups of letters that have the length of your key phrase and encode/decode each group using these functions.
    Moreover, to make things more complicated, hard to break even when using a computer program, you may have an aditional field that holds the date&time when the record was changed, value that you may use to mix-up your key phrase, something like the following:
    -- v$d being the date
    nmixer:=to_number(to_char(v$d, 'mi'))+to_number(to_char(v$d, 'ss'));
    nmixer:=mod(nmixer, 16);
    phrase:=substr(phrase, nmixer, mod(nmixer, 9))&#0124; &#0124;phrase;
    This is what I used and provides a means to actually encode and decode whatever data you need.
    All these functions are stored in the DB in a wrapped package, to be sure not even the DBA can break it.
    Some other way to check, say for a password is to use dbms_utility.get_hash_value, and compare the result of hash_value for the value entered by the user to the hashed value stored in the DB.
    You may choose whatever seems fit for your purpouse.
    Regards,
    BD.

  • Delete duplicate xml element message

    If I coincidently insert into xml type, with duplicate element as below. How would I remove it?
    The duplicate element here is <lastname>
    Thanks for your help,
    Luan
    --- I used this code from example of other forums.
    create table XML_CLOB of XMLType;
    prompt 'insert into XML_CLOB values ( xmltype(<student id="211"><personal idPer="2561"><firstName>John</firstName><middleName>Michael</middleName><lastName>Scott</lastName><birthday>15-11-1984</birthday><address>8600 Beverly Blvd.</address><city>Los Angeles, CA.</city><country>USA</country></personal></student>))';
    insert into XML_CLOB values ( xmltype(
    '<student id="211">
    <personal idPer="2561">
    <firstName>John</firstName>
    <middleName>Michael</middleName>
    <lastName>Scott</lastName>
    <lastName>Scott</lastName>
    <birthday>15-11-1984</birthday>
    <address>8600 Beverly Blvd.</address>
    <city>Los Angeles, CA.</city>
    <country>USA</country>
    </personal>
    </student>'));

    Using your first sample.
    You can count the number of lastName nodes explicitly :
    SELECT XMLQuery(
    'count(/student/personal/lastName)'
    passing object_value
    returning content
    ).getNumberVal() as node_count
    FROM xml_clob
    WHERE existsNode(object_value, '/student[@id="211"]') = 1
    ;or count occurrences of each node, student-wise :
    SQL> SELECT extractvalue(t.object_value,'/student/@id') as student_id,
      2         x.node_name,
      3         count(*)
      4  FROM xml_clob t,
      5   XMLTable(
      6    'for $i in /student/personal/*
      7     return local-name($i)'
      8    passing t.object_value
      9    columns
    10     node_name  varchar2(30) path '.',
    11     posn       for ordinality
    12   ) x
    13  WHERE existsNode(t.object_value, '/student[@id="211"]') = 1
    14  GROUP BY extractvalue(t.object_value,'/student/@id'), x.node_name
    15  ;
    STUDENT_ID                                    NODE_NAME                        COUNT(*)
    211                                           birthday                                1
    211                                           middleName                              1
    211                                           address                                 1
    211                                           lastName                                2
    211                                           firstName                               1
    211                                           country                                 1
    211                                           city                                    1
    7 rows selected
    I wanted to delete the duplicate of <personal idPer="2561">OK, using your second sample, still with deleteXML function :
    UPDATE xml_clob
    SET object_value = deleteXML(object_value, '/student/personal[@idPer=preceding-sibling::personal/@idPer]')
    WHERE existsNode(object_value, '/student[@id="211"]') = 1;It will delete duplicate personal nodes (based on attribute idPer).
    Here, the XPath expression "/student/personal[@idPer=preceding-sibling::personal/@idPer]" selects every personal node having an idPer existing in a previous personal node.

  • Interger.parseInt (PLEASE SOMEBODY HELP ME)

    I'm getting the following error when using Interger.parseInt:
    C:\Binary Files>javac IntsLookup.java
    IntsLookup.java:9: cannot find symbol
    symbol : variable Interger
    location: class IntsLookup
    int x = Interger.parseInt(args[0]);
    ^
    1 error
    So, if anybody kowns how to use Interger.parseInt, Please help. Here is the code that I'm using:
    import java.io.*;
    class IntsLookup{
    public static void main(String[] args){
    try{
    DataInputStream in = new DataInputStream(
    new FileInputStream("IntFile"));
    int x = Interger.parseInt(args[0]); //where the problem is coming
    int count = 0;
    while(in.available()>0){
    int k = in.readInt();
    if(k == x) count++;
    in.close();
    System.out.println(count + " occurrences of" + x);
    catch(IOException e){
    e.printStackTrace();
    With this code I'm just trying to read a binary file called, " IntFile "...
    Please help if you know. Thankx in advance.
    Joyce

    My point exactly. I enjoy helping people with their java problems, that's why I'm here.
    If someone doesn't know it should be Interger instead of Integer, that isn't a java problem. It's a general spelling problem. I'm not going to tell them so. Instead, I'll give them some (sarcastic, yes) hints in the hope that they'll actually learn something. Like where the javadocs are.

  • Efficient string search into files

    Hello, i wrote an application that search a string into several files. At the moment i perform the search looping each files, opening them with new BufferedReader(new FileReader), using .readLine() method to get each line and .indexOf >= 0 to check if the line contains the string to search.
    Is there a more efficient way to do it? Maybe using Scanner class or what else? HasMap? thanks in advance for the replies

    To search for a string in a file you do not have much choice but to read the file and search the characters for the given string.
    If you only need to find the first occurrence of the string then obviously you want to stop reading the file when you have found it (unless you need to do something with the rest of the file). Using a large buffer size might help the reading efficiency of the process. You might check out java.nio for some more efficient ways of reading streams in general.
    I don't see how a HashMap would help with this process unless you need do something along the lines of counting occurrences of multiple strings.
    If all you want to do is search for a string then I am not sure what you would gain using the Scanner class.

Maybe you are looking for

  • I am on Windows 7 with iTunes10.6.1.7 and not able to install 10.7 on a 32bit machine

    The computer is 32bit Dell with 2GB Ram and 2 GHZ

  • User Exit or BADI for Delivery

    Hi, I do have a scenario: In the order If I do have 3 materials A. B and C for Example. If the Stock is not avaliable for materials for A and B, then while creating the deliveries, Delivery will consider materail C. Now I want to restrict this, in th

  • Creation of an event : problem with the container

    Hi Gurus, I'm facing a problem in creation of an event. I'm in SAP ECC 6.0 for a migration project from 4.6B In an ABAP program I'm trying to create an event in order to launch a workflow. 1st step : Set datas in the container -> In INTERNAL_TABLE I

  • Frames missing scroll bar in browser

    I have created a webpage index.html that will be my main page on the web with three frames on it. The top frame will hold the name etc- and the bottom one will hold about 100 small size jpeg pictures that will be linked to display the larger size in

  • Translation of "Invalid Login Credentials" message

    Hi I've application (just) in non-english language. Shared Component / Globalization / Text Messages works well for the translation of "Next/Prev", "Error" texts, but where to translate invalid login error message? Roman