Scan\Look for a particular character in a file

I would like to look for a particular character(@) in a file. The character might be in a word. When if find the character I want to read the actual whole word that contains that character.
What's the best way of going abt this?
Thx,
Kapapra.

Read the file line by line using BufferedReader.
Tokenize each line on space.
Loop through the token strings.
For each token that contains the character that you are looking for (e.g. @) found using indexOf operator of the String class, print or save (or whatever you want to do with that token) that token.
Continue reading the file line by line till the end of the file.
Does this make sense? Look the java.io package API for the details on how to read the file and stuff.
If anyone has more effecient method to do this, please share.

Similar Messages

  • Search for a particular character in a file

    I would like to look for a particular character(@) in a file. The character might be in a word. When if find the character I want to read the actual whole word that contains that character.
    What's the best way of going abt this?
    Thx,
    Kapapra.

    Use StringTokenizer, here is example
    StringTokenizer tokenizer = new java.util.StringTokenizer(yourString, " ");
    while(tokenizer.hasMoreTokens())
       String word = (String) tokenizer.nextToken();
       if ( word.indexOf("@") >=0 )
           // word contains @
      else
            // word does not contain @
    }

  • Looking for a particular vlaue in a id array

    i have a program which generates me 1000000 sample values ie a array of 1 million values.in this 0ne million values i need to look for a particular range of values ie allthe values in the array are 4 and then they ia a value like say 10 and some more values. i need to detect the values greeater than four and then take the 20 values from the index where it is detected. i may have hundered of this pattern in the million samples.

    I am attaching a VI which does what you want. The diagram is pretty straight-forward. Let me know if you don't understand anything.
    Regards,
    Khalid
    Attachments:
    chkarray.vi ‏34 KB

  • Looking for a particular email

    I have Mail backed up to TM as well as an external drive. I am looking for a particular email that has been backed up. I moved the particular mailbox from each of these drives to my desktop. They are .imapmbox files and would like to import these messages into Mail as a separate disposable folder.
    On the desktop they are #.emix files which are not easy to search.
    How to do this?
    Thanks

    I'm not sure. I know you can import mail stored locally by opening Mail and selecting Import from the File menu. Select the Apple Mail option then follow directions. A file Open dialog will appear and you must navigate to the /Users/username/Library/Mail/ folder and select the Mailboxes folder. If your mail is there then you can select the mailbox and import it. However, this does not work for IMAP accounts. Make a copy of the .mbox file that should have your mail. Again select Import from Mail's File menu. Select the bottom option to import .mbox mail and follow directions.
    Imported mail will appear in a separate sidebar header called Imported Mail.

  • Code for reading particular  fields from the file placed in application

    hi,
    code for reading particular  fields from the file placed in application server in to the internal table.

    Hi,
    Use the GUI_UPLOAD FM to upload the File into ur Internal Table.
    DATA : FILE_TABLE TYPE FILE_TABLE OCCURS 0,
             fwa TYPE FILE_TABLE,
             FILENAME TYPE STRING,
             RC TYPE I.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
      EXPORTING
        WINDOW_TITLE            = 'Open File'
       DEFAULT_EXTENSION       =
       DEFAULT_FILENAME        =
       FILE_FILTER             =
       INITIAL_DIRECTORY       =
       MULTISELECTION          =
       WITH_ENCODING           =
      CHANGING
        FILE_TABLE              = FILE_TABLE
        RC                      = RC
       USER_ACTION             =
       FILE_ENCODING           =
      EXCEPTIONS
        FILE_OPEN_DIALOG_FAILED = 1
        CNTL_ERROR              = 2
        ERROR_NO_GUI            = 3
        NOT_SUPPORTED_BY_GUI    = 4
        others                  = 5
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    READ TABLE FILE_TABLE INDEX 1 into fwa.
    FILENAME = fwa-FILENAME.
        CALL FUNCTION 'GUI_UPLOAD'
             EXPORTING
                  filename                = filename
                  FILETYPE                = 'DAT'
           IMPORTING
                FILELENGTH              =
             TABLES
                  data_tab                = itab
             EXCEPTIONS
                  file_open_error         = 1
                  file_read_error         = 2
                  no_batch                = 3
                  gui_refuse_filetransfer = 4
                  invalid_type            = 5
                  OTHERS                  = 6 .
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    Regards,
    Balakumar.G
    Reward Points if helpful.

  • How to look for a particular phrase in a document???

    Hey guys, I'm a little new at this thing... I need to figure out a way to make Java search through a document looking for instances of particular phrases, and replacing them with something else. For example, have it look for "A B C" and replace each such combination of words with "D E F". The search/replace needs to look for a few different phrases at once.

    String.replaceAll is a fine answer, but you are creating Strings left, right & center, tis best to use a StringBuilder/Buffer.
        private static void replaceAll( StringBuilder sb, String search, String replace ) {
         int index = sb.indexOf( search, 0 );
         while( index >= 0 ) {
             sb.replace( index, index+search.length(), replace );
             index = sb.indexOf( search, index );
        }

  • Looking for a particular number, possible?

    Hi there,
    I need to get a particular number, similar to my business name. 
    example: my business name abcdef.
    Now, i am looking for a USA number at the end it will have (*** 222 333) ->(*** abc def)
    any one point me where can i get help to choose this kind of particular number? Or its not possible at all?
    Thank you.

    Hi, Smahi, and welcome to the Community,
    You would need to search through the lists of numbers presented when you arrive at the step to choose your Skype Number in order to determine if the precise numbering sequence is available.  Skype Customer Service is not able to start a subscription, and nor can they search the Skype Number databases to check for available numbers.
    Good luck!
    Regards,
    Elaine
    Was your question answered? Please click on the Accept as a Solution link so everyone can quickly find what works! Like a post or want to say, "Thank You" - ?? Click on the Kudos button!
    Trustworthy information: Brian Krebs: 3 Basic Rules for Online Safety and Consumer Reports: Guide to Internet Security Online Safety Tip: Change your passwords often!

  • Looking for a particular set of features

    Does anyone know what Abode product will allow me to write with a stylus (on a Sony tablet) on a PDF and at the same time redord audio.  And then allow it to be played back.  I am math a teacher and I would like to upload an example question (PDF) for my students into a program.  then i would like to be able to complete the example by writing with my touch screen and i would like some audio to acompany it.  Then i want to save this and post on my class web page.   
    Are there and porduct out there that do that?

    Hi,
    Check for the fiscal year variant value for that  fisal period 003/2007in the cube is it same as that of othertwo values of the fiscal period.
    May be at the report level or at the cube level you have restricted the values of the fisacl variant for a particular value and for that variant value there is no fiscal period of 003/2007.
    Also it may be possible that your report key figures are restrcited year to date... that is till current fiscal period only through some other way.. and thats why you can only see data till current fiscal.
    Hope it helps
    Thanks

  • Looking for a particular font

    I'm looking for this font to use with final cut pro 6.0.1:
    http://img223.imageshack.us/img223/9837/fonthk4.png
    where can I download it?

    Aren't you using it? I mean, the link shows YOUR NAME.
    What is the name of the font? Google that and then you'll find it. Might have to pay for it, but such is life.
    Shane

  • Looking for a particular color correction tutorial

    I am looking for an online tutorial on how to do color correction if the video one is working with has color bars.  This happens on a lot of analog videotapes that come to me.  I know what my scopes are suppposed to look like when analyzing color bars, but I need something that shows me how to get from A to B.
    If I Google some varient of "color correction video color bars," all I get is information on calibrating monitors.
    I am using Premiere CS5.5
    Thanks in adavnce for any response!
    J. D.

    APP - Layer...
    Also... Check this site for looking at APPs.. I've posted this before but it's a good site. It just started up a week or so ago.
    http://androidapplications.com/

  • Looking for a particular BAPI for VB01

    Hi everyone,
    I'm looking for a BAPI i could use VB01 to tie finish goods to customer.
    I have got 5000 materials for my conversion, and each customer can tie to many materials, any ideas on this?

    Hai bernard,
    try this BAPI.
    BAPI_CUST_SAREAS_MATERIALS_GET -
    Create List of Materials for the Sales Areas of a Customer.
    REGARDS,
    PRABA.

  • Looking for a particular 1pad2 case

    I am looking for a case for the ipad2.  the case must protect the ipad2, without covering up ports and camera.  the kicker is, it needs to have a shoulder strap attached in order to be worn around the neck.

    love the new Vaja case, specially the black and red one. I had it for couple of weeks and it looks amazing.

  • How to look for a particular field in the segments of IDOC ?

    Hi,
    I am looking at a particular IDOC which I will use to do data trasfer from lgacy to R/3 using BAPI in LSMW. Now I know a field which is required to create a given business transaction when igrating data. But there are 100's of segments on the IDOC.
    Is there a way I can see if the given field is present in any of the IDOC segment ? I don't want to dig though each and everys egment and find it out...
    Regards,
    Rajesh

    Try using WE09..There you have the option of searching by the idoc data..CHeck in the bottom of the selection screen
    Thanks,
    Naren
    Message was edited by: Narendran Muthukumaran

  • Looking for help with converting a ppsx file to a video format such as .mov or mp4

    Hi All,  I am looking for conversion software that will allow me to convert a ppsx file to a video file on OS10.5.8. 

    Hi Klaus1, Thanks for your response.  I can open and view the file without difficulty.  My issue is getting into a video format that I can upload to a Website for client viewing.  All the conersion products I can find are for a newer OS then 10.5.8.  I am working on a deadline of midnight tonight-and cannot upgrade that quickly.  So What I need is a conversion program that will still run on my OS

  • Want to know how to check for new line character in text file

    Hi All,
    I`m trying to read data from text file. However I`m not sure whether the data is in 1st line or nth line. Now I`m trying to read the text from the readline. But if text is "" and not NULL then my code fails. So I want to know how to check for new line character and go to next line to find the data. Please help.
    Thanks
    static int readandwriteFile(Logger logger,String filepath){
              BufferedWriter out = null;
              BufferedReader in = null;
              File fr = null;
              int get_count = 0;
              try     {
              if(new File(filepath).exists())
              fr= new File(filepath);
                        System.out.println("FileName: "+fr);
                   if(fr != null){
    in = new BufferedReader(new FileReader(fr));
                             String text = in.readLine();
                             if(text != null){
                             get_count = Integer.parseInt(text);
                             in.close();
                             else{
                                  get_count = 0;
         else{                    
    out = new BufferedWriter(new FileWriter(filepath));
         out.write("0");
                out.close();
                   }          //Reading of the row count file ended.
              catch(Exception e) {
                   e.printStackTrace();
              finally {
                   try{               if (in != null) {
                             in.close();
              if (out != null) {
                             out.close();
              catch(Exception e) {
                        e.printStackTrace();
              return get_count;
         }

    You are calling the readline() only once which means you are reading only the first line from the file...
    Use a loop (Do-While preferably)
    do{
    //your code
    }while(text == "")

Maybe you are looking for