Quick Question on String Searches

I'm about to write a small program to find a target string in any file format, then display the target string and the first 200 characters before and 200 characters after the target string to the console. I want to use OOP, using main() for testing purposes only, but I'm not sure of the best way to approach this. Should I use the store() and load() methods from Properties or just use indexOf()? Any thoughts, folks? Thanks.

If fyou are going to be searching in any file format (including binary files such as Word docs) then you can't really use the indexOf or the Properties class (I am not sure what your intentions were with the Properties class, but using it requires a particular file format).
Just off the top of my head, I would suggest using a RandomAccessFile and seeking around, reading data into buffers when you find what you want. To me, this isn't exactly a job for OOP, at least at its guts. You can use OOP to come up with a design - perhaps using specific "Searchers" tuned to particular file formats, and then have a driver class that determines, at runtime, which Searcher class to use for a given file. But again, that's just off the top of my head.
Good Luck
Lee

Similar Messages

  • A quick question of String

    how to check whether it starts with digitals or not? i remember there is a quick solution but i forget it.
    i checked the books but found no answer. could anybody tell me? Thanks!

    Maybe this will work:
    String s = "1abc";
    try{
    Integer.parseInt(s.substring(0,1));
    catch (NumberFormatException e){
    System.out.println("1st char is not a integer");

  • Quick question on KEYWORD Search

    Hello,
    Any idea how does a Keyword Search works ..Could not find any good documentation .
    I have an issue with customer where they are doing a key word search on 3 words and not pulling the data since all the 3 words are not matched.If we try to do a search with 2 matching words it pulls up the data.
    Its in iRecruitment Vacancy search feature which uses Oracle text.
    How to do Keyword search with multiple words for an AND and OR Condition.
    Appreciate your help.
    Thanks,
    Gopi

    From Technet:
    Role-based administration does not support an explicit deny action on security roles, security scopes, or collections assigned to an administrative
    user. Instead, configure security roles, security scopes, and collections to grant permissions to administrative users. If users do not have permissions to objects by use of these role-based administration elements, they might have only partial access to some
    objects, for example they might be able to view, but not modify specific objects. However, you can use collection membership to exclude collections from a collection that is assigned to an administrative user.
    Cheers
    Paul | sccmentor.wordpress.com

  • Problem in String Search using OKAPI in 9i Lite

    We are creating an Symbian EPOC application using Oracle 9iLite in stand-alone mode. We have managed to create a C++ program that creates an Oracle database on the Nokia Communicator 9210.
    The problem is that a string search returns either null or all of the searched records, ie. it does not work.
    The code below should do the string search and return the strings that match the given keyword. Any idea why this is not working? We are using OKAPI.
    TempCond[0].Operator = OK_GT;
    TempCond[0].AttrPos = KEYWORDREFERENCE_INDEX_FOR_KEYWORD;
    TempCond[0].AttrVal.BufPtr = (unsigned char*) szGivenKeyword;
    TempCond[0].AttrVal.BufSize = OK_NEW_ARRAY | strlen szGivenKeyword);
    TempCond[0].AttrVal.Indicator=1;
    TempCond[0].Collate=0;
    TempCond[0].Connective=OK_AND;
    // Iterate through the entire group, extracting the key data
    //(whatever the key may be) and the object reference, and
    // append to the end of the array.
    e = okCreateIterator( iEnv,
    iEbmgKeywordReferenceGroupRef,
    iEbmgKeywordReferenceClassRef,
    FALSE,
    1,
    TempCond,
    20,
    0,
    NULL,
    &iter
    Thanks for any help you may provide.

    I am sorry, this is not an answer to your question but a little help from you is well appeciated.
    I have just started exploring oracle 9i Lite to develop apps. on Palm and WinCE using OKAPI but the documentation does not seem enough. Is there some book or sample programs available that demonstrate OKAPI to develop form based apps ? CodeWarrior and Satellite Forms are not good when someone wants to try writing demp app.
    Thanks,
    Ashish

  • Re-importing into iPhoto 06 Quick Question

    I hope.
    My photos are on an external hard drive. I jogged the wire the other day during an import and stopped the import. When I next loaded up iPhoto all the photos had changed to ! , so I reimported them, which all worked fine, but it's reimported everything including the thumbnails, so I now have every picture at least twice and want to get rid of all the small sized files.
    Can I do it a quick way like search for photos below a certain size or should I import from a different point? I imported from the iPhoto directory, but should I have been a bit more specific on a sub directory? I want to make sure I get the original photos and any photos I've edited.
    Finally, should I delete the existing thumbnails in one of the directories before I re-import?
    Thanks

    It’s not a quick question.
    so I reimported them, which all worked fine, but it's reimported everything including the thumbnails, so I now have every picture at least twice
    This was not the way to go about this. You’ve now imported to a damaged database and that is inherently unstable.
    There is no way to search on file size in iPhoto. You may have some luck with Duplicate Annihilator
    However, do you still have the original library? If so, here’s how to start over:
    Try these in order - from best option on down...
    1. Do you have an up-to-date back up? If so, try copy the library6.iphoto file from the back up to the iPhoto Library allowing it to overwrite the damaged file.
    2. Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one.
    3. If neither of these work then you'll need to create and populate a new library.
    To create and populate a new library:
    Note this will give you a working library with the same Rolls and pictures as before, however, you will lose your albums, keywords, modified versions, books, calendars etc.
    Move the iPhoto Library to the desktop
    Launch iPhoto. It will ask if you wish to create a new Library. Say Yes.
    Go into the iPhoto Library on your desktop and find the Originals folder. From the Originals folder drag the individual Roll Folders to the iPhoto Window and it will recreate them in the new library.
    When you're sure all is well you can delete the iPhoto Library on your desktop.
    In the future, in addition to your usual back up routine, you might like to make a copy of the library6.iPhoto file whenever you have made changes to the library as protection against database corruption.
    Regards
    TD

  • Quick question about RegExp

    Just a quick question.
    In other languages, I can do this...
    while(reg.exec(string)) {
         //loop through results
    And while looping, I can access the current match with something like reg.Match or whatever. 
    Is this possible in AS?

    Look up the RegExp class.

  • Need a quick answer on advanced search parameters

    I am an IT professional, but am not a regular Thunderbird user. I have an e-discovery need to search for multiple terms in a mailbox. The best solution I have found for this is to export the mailbox from Google Apps as an .mbox, and use the importexporttools extension for Thunderbird to import the .mbox.
    I then have the mails in a local folder, and right-click on the folder and click on search messages. A number of filters appear, and I put in my terms, select to search within body, for Any results.
    This works fine for me but I have two questions:
    1. How can I search for something with an apostrophe in it?
    For example, if I needed to search for:
    '123abc
    How would I do it? Quotes? Is there an escape character to state that that needs to be taken literally and isn't a quote or part of a command?
    2. Does the search I am performing, or any other way of searching, search within attachments? In Google Apps I can search within attachments - such as text files, or Microsoft Office documents. Is this possible to do?
    I searched through the help files and FAQs, but I am not sure if I am using quick filter, or global search etc.
    Thanks!

    There are different methods of searching.
    '''Quick Filter:'''
    The Quick Filter can be used to search in the selected folder. There are additional filters to refine the search.
    * https://support.mozilla.org/en-US/kb/quick-filter-toolbar
    '''Global Search: '''
    The Global Search can be used to search all accounts. There are additional filters to refine the search.
    * https://support.mozilla.org/en-US/kb/global-search
    '''Account and folder specific Search:'''
    'Edit' > 'Find' > 'Search Messages'
    or
    'Menu Icon' > 'Find' > 'Search Messages'
    A new window opens.
    At the top you will see: 'Search for messages in' and you can select the mail account or specific folder from the drop down selection. You can choose to 'Search subfolders' if required.
    If you are using one search criteria (condition) or more than one but they all must be true, then select 'Match all of the following' option If you are using more than one condition, but any, not necessarily all, can be true, then use 'Match any of the following'.
    example test:
    Using Account and folder specific Search method.
    I set it to search a particular folder.
    selected: 'Body' and 'Contains' and typed: "new
    click on 'Search' button
    It returned only one message.
    when I removed the quote mark so it only said: new (not "new)
    clicked on search and it returned several possibilites.
    So this worked, returning exactly as required.
    When I used the 'Global Search' on same folder typing: "new
    It returned a search only on : new
    Quick filter method also failed to recognise the " used before new.
    So in this instance of searching on: "new
    neither Global Search nor Quick filter returned the best result although the message required was included in the selection returned.
    The best method which worked as required was Using Account and folder specific Search method.
    You can search to return any emails with attachments using 'Account and folder specific Search' method.
    Quick Filter and Global filter will search on whether the word 'attachments' is in the eg: Body of email, but not necessarilly locate emails with attachments.
    Global search will search to include attachment filenames.
    Quick filter does not.
    As far as I'm aware, you cannot search the contents of an attachment.

  • Train stops distance - quick question

    Hi
    How do we control/modify the train length between the train stops ?
    We have one longer than the other of the 3 stops. It looks like its because one string of the stop is longer than the other.
    We like to spread them out wider so that the 2 lengths will be equal.
    Right now
    Also, Another quick question - It appears that the 3-stop train we have are placed differently in different browser.
    In IE, the train is positioned to the left
    In Firefox, the train is positioned in the center.
    How do we make all browsers to show the train in the center ?
    Thanks
    Edited by: 898644 on Sep 21, 2012 1:36 PM

    use css styling and skinning refer
    http://jdevadf.oracle.com/adf-richclient-demo/docs/skin-selectors.html#af:train

  • Question about string manipulation

    Hello, I am practicing with Java and trying to learn it, and have a quick question. I am trying to get the count on a string of numbers for after a decimal point. the numbers are generated as the result of a math, so I can't use index, since the location of the decimal changes based on the number imputed. I want to figure this out on my own, but have hit a wall here, i've spent the past few hours trying every string command I can think of, and haven't figured it out yet, anyone mind pointing me in the right direction for which string to use? Thanks in advance for any help you can provide!

    Is this what you want?
    public class Fallen{
      public static void main(String[] args){
        String number = "123.45678";
        String frac = number.substring(number.indexOf('.') + 1);
        System.out.println(frac + " length=" + frac.length());
        frac = number.replaceFirst("^.+\\.", "");
        System.out.println(frac + " length=" + frac.length());
    }

  • Silent installs - quick question

    Hi All
    We like to confirm if silent installations both 32-bit and 64-bit java jdk installs support installation directory option.
    Eg
    On 64-bit JDK
    jdk.exe /s /v/qn INSTALLDIR=C:\software_installations\jdk1.6\ /L C:\software_installations\scripts\auto-install.log\
    We ask because we keep getting pop-ups on options to install but it doesnt have INSTALLDIR option.
    Does 32-bit JDK have different options ?
    What are the exact command string including option of install directory ?
    We like to silent install our 32-bit and 64-bit JDKs with our custom install directory, not using the default.
    Thanks

    No multiposting, please. One thread is enough.
    silent installs - quick question
    Moderator action: I'm locking this thread

  • Approximate string search

    Hi everyone,
    If anyone here is interested in approximate string search algorithms, take a look at this prototype: http://scientechs.com/servlet/smartsearch.test.ApproxiMatchServlet . Keyword DB was compiled from the list of canadian business names and has right now ~200K of words, so don't expect to find every english word there.
    Source code would be uploaded to sourceforge soon (smartsearch.sourceforge.net). If anyone wants to participate in improving the project, drop a note. All feedback is welcome.

    From the description:
    "Approximate string search algorithm implementation (the algorithm was developed from the scratch, so it is NOT an implementation of existing algorithms), written in Java and runs under any OS that supports Java2 platform."
    I know there are a number of approximate string matching out there. My question is how does your algorithm relate to the other ones?
    I tried keyword apple, so it seems there is more work to do, but at least it worked.

  • Just A REal Quick Question

    Hey Folks,
    I just have a quick question... LoL, like the subject header thing says...
    Does anyone know where i can find a list of games that will run on just a macbook?
    so that i don't have to go through every game and look at the specs.... i can just look at the list and jump to that game and see if i want to buy it...

    try google searching ...."games that work on GMA 950 chipset" which should produce a wiki page
    the GMA 950 is the graphics card in Macbook and is poor for gaming as I found out but GOOD LUCK

  • Report Generation Toolkit Error Quick Question

    Hi,
         I created the most awesome LabVIEW report ever at my desk using a trial version of the RGT and Office 2003.  I took this to my production machine and ")@#(&%(*#^%()^!!!"  The production machine has office 2007 and a fully licensed version of the RGT.  Both machines have LabVIEW 8.6.0.  I've read all the stuff about these errors and something about classes and dll's and whatnot's.  So my quick question, is:  Instead of matching the versions of Microsoft Office as recommended, can I just rewrite from scratch the VI that creates this world's most awesome LabVIEW report on the production machine to create the same effect? 
    Solved!
    Go to Solution.

    Hi 
    Quick Answer: Probably
    Slower answer: Microsoft changed a lot of things behind the scenes in Office 2007, but the Report Generation toolkit version 1.1.3 supports Office 2007 so you should be good to go. Depends on what functions are included in your VI. Liek the read me says "Several default settings in Microsoft Office 2007 differ slightly from previous versions. Reports you generate using Office 2007 might look different than reports you generate from other versions of Office because font sizes, cell sizes, and so on, differ."
    Best Regards
    David
    NISW

  • Two quick questions about Library after moving beginning on a new computer

    Hi there,
    I just moved from Windows to Mac, meaning I had to move my iTunes library from the old PC to my new MBA.
    Just a couple of quick questions.
    1. When I started iTunes on my new Mac, in the preferences I directed the media folder to the folder with all my itunes music/podcasts etc, and then I imported the Library XML file.  Is this incorrect? Should I have imported a different file? Should I have used the itl file instead? 
    If so, should I delete the library and start again?  (if this is the case, please suggest the best way of doing this without affecting my media)
    - a kind of sub-question to this one:  some of the media files arent showing up in the iTunes library, but they are in the media folder on the ext HDD.  Is there a way I can find out which ones havent been recognized by iTunes?  Whats the best way of getting them in to my library?
    2. Pretty much half of my podcasts have not been loaded in the new iTunes.  The ones that havent were ones that I subscribed to on my iPhone, whereas the ones that show up in iTunes were ones I downloaded from iTunes.  When I connect my iPhone and sync it with iTunes, will those podcasts show up in iTunes?  Or is there a risk that they will be deleted from my iPhone?
    Cheers,

    The .xml is lacking some information such as ratings, date added, and play count.  Using the .itl includes this information but cannot be imported using the method you did.
    A complete library is everything in the iTunes folder.  By using the method you did you left the artwork behind in the artwork folder on the other machine.
    Selecting the media folder in preferences does not get iTunes to recognize the media.  All it does is tell iTunes to start storing new media in that location.
    Using the method I outlined nothing will be missed (with the exception of WMA) because you aren't rebuilding your library, you are using the one that already exists.
    You don't have to re-copy everything as long as you get the stuff you missed and re-assemble it all as it was before except not on the Mac.
    What are the iTunes library files? - http://support.apple.com/kb/HT1660
    More on iTunes library files and what they do - http://en.wikipedia.org/wiki/ITunes#Media_management
    What are all those iTunes files? - http://www.macworld.com/article/139974/2009/04/itunes_files.html
    Where are my iTunes files located? - http://support.apple.com/kb/ht1391

  • How to implement Quick Query and Saved Searches in ADF?

    We are using 11gR2 ADF.
    The requirement is to enable Quick Search and save the Searches.
    In the Oracle ADF documentation, it is mentioned that
    - Create a view with view criteria named.
    - In the .jspx drag and drop the view criteria and Select Quick Query
    Upon doing the above, we see that a Search panel is getting created, but with a message 'No Search Fields Added'.
    In the named view criteria, Under 'UI Hints' we have set
    -- execution mode as Both
    -- Search region mode is Basic
    -- Show Operators in Basic
    Under 'Criteria Definition'
    the attributes are added in a group with OR condition.
    Thanks for your reply. Oracle ADF developer guide does not help!!
    If you have any other documentation that helps in implementing this Quick Query and Saved Search, your help is greatly appreciated.

    Set the following on your af:query component
    SaveQueryMode = hidden
    ModeChangeVisible = false
    This should work for you ..
    Regards,

Maybe you are looking for