How to check on-thy-fly dynamic txt-files

hello.
i want to check out a dynamic txt-file (dynamic, because it is a running log from a chat) for specific words.
the program should start to check the incoming content at the actual end of the file(previous content is in this case uninteresting) and shouldn't stop to do that(unless i want it).
my problem is, that the program stops after it reachs the end of the file.
any idea?
many thx.
try
          String zeile;
//Wir lesen aus "eingabe.txt".
          File eingabeDatei = new File(new URI("file:///C:/Log.txt"));
FileReader eingabeStrom = new FileReader(eingabeDatei);
BufferedReader eingabe = new BufferedReader(eingabeStrom);
while ((zeile = eingabe.readLine()) != null)
     Pattern p = Pattern.compile("TESTWORD");
// Muster: Ziffer, mind. ein Buchstabe, Ziffer
Matcher m = p.matcher(zeile);
if (m.find())
     Robot rob = new Robot();
     rob.keyPress( '1' );
System.out.println (m.group());
     System.out.println("Pattern at Pos. " + m.start());
System.out.println("Pattern is: " + m.group());
else
System.out.println("***No pattern found***");
//System.out.println(zeile);
} catch (IOException e)
e.printStackTrace();
}

hello.
i want to check out a dynamic txt-file (dynamic,
because it is a running log from a chat) for specific
words.
the program should start to check the incoming
content at the actual end of the file(previous
content is in this case uninteresting) and shouldn't
stop to do that(unless i want it).
my problem is, that the program stops after it reachs
the end of the file.
any idea?
many thx.
Please use the code tag next time you post code. Thanks.
(see more comments below)
try {
     String zeile;
     //Wir lesen aus "eingabe.txt".
     File eingabeDatei = new File(new URI("file:///C:/Log.txt"));
     FileReader eingabeStrom = new FileReader(eingabeDatei);
     BufferedReader eingabe = new BufferedReader(eingabeStrom);
     while ((zeile = eingabe.readLine()) != null)
          Pattern p = Pattern.compile("TESTWORD");
          // Muster: Ziffer, mind. ein Buchstabe, Ziffer
          Matcher m = p.matcher(zeile);
          if (m.find())
               Robot rob = new Robot();
               rob.keyPress( '1' );
               System.out.println (m.group());
               System.out.println("Pattern at Pos. " + m.start());
               System.out.println("Pattern is: " + m.group());
          else
               System.out.println("***No pattern found***");
          //System.out.println(zeile);
catch (IOException e) {
     e.printStackTrace();
}The line:
while ((zeile = eingabe.readLine()) != null)is why your app quits. The while loop ends on null which happens when there is nothing to read from the reader
From the API:
Returns:
A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached.

Similar Messages

  • How to check whether there r new txt files in a folder n file creation date

    How to check whether there r new text files in a specified folder and what is the date of creation of the text file.........?

    Hi
    I have been searching for a solution to find the date of creation of a file for over 6 months now but haven't found it. So I presume that it is not possible though I havent found any authentication of my assumption in any document.
    Cheers!
    Shailesh

  • How to check if the content in txt file is empty

    hi, i need my program to check if the content in txt file is empty. can anyone demonstrate an example with if-else statement ?

    I assume you already have file object
    File file = new File("path");
    if (file.length() == 0) {
      System.out.println("File size is 0");
    else {
      System.out.println("File size is " + file.length());
    }Read API here:
    http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#length()
    Edited by: Kunkhmer on Feb 26, 2008 1:57 PM

  • How to check the resolution of a pdf file using Acrobat 9 pro?

    How to check the resolution of a pdf file using Acrobat 9 pro?

    PDF files don't have one resolution, but may have none or many different resolutions, one per image. You can check the maximum/minimum resoluion with preflight in Acrobat Pro, but not in Adobe Reader.

  • How to search a special string in txt file and return it's position in txt file?

    How to search a special string in txt file and return it's position in txt file?

    I just posted a solution for a similar question here:  http://forums.ni.com/ni/board/message?board.id=170​&view=by_date_ascending&message.id=362699#M362699
    The top portion can search for the location of a string, while the bottom portion is to locate the position of a character.  Both can search for a character.
    The position of the character within the file is displayed in the indicator(s).
    R

  • How can i open a DOC or TXT file and insert the data into table?

    How can i open a DOC or TXT file and insert the data into table?
    I have a doc file . the doc include some columns and some rows.(for example 'ID,Name,Date,...').
    I'd like open DOC file and I'd like insert them into the table with same columns.
    Thanks.

    Use the SQL*Loader utility or the UTL_FILE package.

  • How to check particular error in alert log file

    Hi all,
    How to check particular error in alert log file,for supose if i get error in batabase yesterday 4 pm & today i want to check alert log file to get basic idea..it might be a big file so how to check that particular error..
    Thanks & regards,
    Eswar..

    What's your oracle version?
    If you are in 11g you can use adrci tool
    1- set homes diag/rdbms/orawiss/ORAWISS/ : the rdbms home
    2- show alert -P "MESSAGE_TEXT LIKE '%ORA-%'" -term : to find all the ORA-% errors in the alert file
    3- show alert -P "MESSAGE_TEXT LIKE '%ORA-%' and originating_timestamp > systimestamp-51 " -term : to find all the ORA-% errors in the alert file during the last 51 days,
    4- show alert -P "MESSAGE_TEXT LIKE '%ORA-%' and originating_timestamp > systimestamp-1/24 " -term : to find all the ORA-% errors in the alert file during the last hour,
    5- show alert -P "MESSAGE_TEXT LIKE '%ORA-12012%' and originating_timestamp > systimestamp-1/24 " -term : to find the particular ORA-12012 error in the alert file during the last hour,
    Example:
    [oracle@wissem wissem]$ adrci
    ADRCI: Release 11.2.0.1.0 - Production on Wed May 4 10:24:54 2011
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    ADR base = "/home/oracle/app/oracle"
    adrci> set homes diag/rdbms/orawiss/ORAWISS/
    adrci> show alert -P "MESSAGE_TEXT LIKE '%ORA-'" -term
    ADR Home = /home/oracle/app/oracle/diag/rdbms/orawiss/ORAWISS:
    adrci> show alert -P "MESSAGE_TEXT LIKE '%ORA-%'" -term
    ADR Home = /home/oracle/app/oracle/diag/rdbms/orawiss/ORAWISS:
    2010-12-11 19:45:41.289000 +01:00
    ORA-1109 signalled during: ALTER DATABASE CLOSE NORMAL...
    ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
    ORA-01152: file 1 was not restored from a sufficiently old backup
    ORA-01110: data file 1: '/home/oracle/app/oracle/oradata/ORAWISS/system01.dbf'
    ORA-1547 signalled during: ALTER DATABASE RECOVER  database until time '2011-01-21:10:48:00'  ...
    Errors in file /home/oracle/app/oracle/diag/rdbms/orawiss/ORAWISS/trace/ORAWISS_j000_5692.trc:
    ORA-12012: error on auto execute of job 29
    ORA-01435: user does not exist
    2011-03-15 11:39:37.571000 +01:00
    opiodr aborting process unknown ospid (31042) as a result of ORA-609
    2011-03-15 12:04:15.111000 +01:00
    opiodr aborting process unknown ospid (3509) as a result of ORA-609
    adrci>
    adrci> show alert -P "MESSAGE_TEXT LIKE '%ORA-%' and originating_timestamp > systimestamp-51 " -term
    ADR Home = /home/oracle/app/oracle/diag/rdbms/orawiss/ORAWISS:
    2011-03-15 10:19:45.316000 +01:00
    Errors in file /home/oracle/app/oracle/diag/rdbms/orawiss/ORAWISS/trace/ORAWISS_j006_5536.trc:
    ORA-12012: error on auto execute of job 26
    ORA-01435: user does not exist
    Errors in file /home/oracle/app/oracle/diag/rdbms/orawiss/ORAWISS/trace/ORAWISS_j000_5692.trc:
    ORA-12012: error on auto execute of job 29
    ORA-01435: user does not exist
    2011-03-15 11:39:37.571000 +01:00
    opiodr aborting process unknown ospid (31042) as a result of ORA-609
    2011-03-15 12:04:15.111000 +01:00
    opiodr aborting process unknown ospid (3509) as a result of ORA-609
    adrci>

  • How to read the data in a txt file on a web site?

    I want to extract the numbers located in txt files on a web site. It's a normal url. Not a ftp.
    Does anyone know how to do it?

    Hi Tom,
    What do you want to extract from the text file??
    I wanted to extract an IP address from a pearl script from my FTP server and this was the vi that I used .I dont know if you are trying to do the same?
    Here is the vi.It is in LV 7.1
    Hope its helps .
    Good luck.
    ohiofudu.
    Certified LabVIEW Architect
    Certified TestStand Developer
    Attachments:
    PublicIP-Adresse.vi ‏31 KB

  • How to read Chinese word from a TXT file

    File.OpenText() read a TXT File with  Chinese word in   ;but it not show right.
    exam:The TXT File include :中国
     this.Txt1.Text=ofd.File.OpenText().ReadToEnd();
    but it show :��ʹ�ݼƻ��
    How to solve it

    What encoding does the text file use?  Unlike .NET, Silverlight only supports UTF-8 and UTF-16.  File.OpenText() uses UTF-8 by default.
    If the text file is in some other encoding, you can create your own encoding class (that derives from System.Text.Encoding) that can be used to read the text file.
    class MyEncoding : System.Text.Encoding {
    this.Txt1.Text = (new StreamReader(ofd.File.OpenRead(), new MyEncoding())).ReadToEnd();
    Regards,
    Justin Van Patten
    Program Manager
    Common Language Runtime

  • How to skip first TWO Lines of   .txt  file    using XSLT Mapping

    Hi Friends  ,
                              I have an .txt file in has the format as
                               <TEST>
                                4564564545
                                56456444566
                                56465
                                    How can i skip the first two Lines when i am writing the XSLT Mapping ?
                              That <TEST> and empty line shouldn't go the rfc  .
                             How can i skip and sent to rfc  using XSLT Mapping ?
    Best Regards .,
    V.Rangarajan

    you can avoid the empty lines in your File Content Conversion by defining offset.
    <i>Under Document Offset, specify the number of lines that are to be ignored at the beginning of the document.
    This enables you to skip comment lines or column names during processing. If you do not make an entry, the default value is zero lines.</i>
    ref: http://help.sap.com/saphelp_nw04/helpdata/en/2c/181077dd7d6b4ea6a8029b20bf7e55/content.htm
    then the generated XML after FCC will not have the empty lines.

  • How to use certain entries from a txt file as metadata?

    So during my plugin development I stumbled on a problem.
    I have created a txt file for each picture telling me who's in the photos. So the first column in the file shows all the names that appear in the photo.
    I want to add those names into LR for each photo. I thought using them as metadata would be a good idea. Then I could let the user enter a name of some person and create a smart collection having all photos with that person in them.
    But putting it into practice isn't that easy.
    So I started with the classic metadata definition:
    metadataFieldsForPhotos = {
      id = 'Person',
      title = 'Person'
      dataType = 'string',
      searchable = true,
      browsable = true,
    Now I don't know how to actually read only the column entries of the txt file and displaying all the names appearing in it. Another problem is that each photo has its own txt file in "nameofphoto.jpg.txt" So LR must know which txt file belongs to a photo.
    I know my question isn't very specific but it would be great if someone could help...

    Thank you for the reply. Reading the file how I wanted worked fine and I chose to use keywords, as you suggested.
    So now I tried to add the keywords to the pictures and I get:
    "LrCatalog:withWriteAccessDo: could not execute action 'keywordProvider'. It was blocked by another write access call, and no timeout parameters were provided."
    There's my function so far:
    function Finder.findPerson(smartCollectionName)
         local catalog = LrApplication.activeCatalog()
         local photos = catalog:getMultipleSelectedOrAllPhotos()
           LrTasks.startAsyncTask( function()
                for i=1,#photos do
                     local photo = photos[i]
                     local photopath = photo:getRawMetadata("path")
                     local photoname = photo:getFormattedMetadata("fileName")
                     local folderpath = string.sub(photopath, 1, string.len(photopath) - string.len(photoname))
                     local metadataPath = folderpath .. "\.metaface\\" .. photoname .. ".txt"
                     local text = LrFileUtils.readFile(metadataPath)
                     local metadataValues = stringSplit(text)
                     for i = 0, #metadataValues do
                          catalog:withWriteAccessDo( "keywordProvider", function()
                               local keywords = catalog:createKeyword(metadataValues[i])
                               photos:addKeyword(keywords)
                          end)
                     end
               end
          end)
    end
    So what am I doing wrong?

  • How to store the datas in a .txt file in to a JTable in Java Swing

    Hi sir,
    Here i want to know how to store the data's of a .txt file
    in to a JTable in java swing.
    Where here the .txt file like for eg,spooler.txt is in the server and from there it will come to my client machine what i have to do is to take that .txt file and store the datas of the .txt file
    in a JTable.This is what i want.So pls. do help and provide the code as well.I will be thankful.Since i am involved in a project which involves this it is Urgent.
    Thanx,
    m.ananthu

    You can't just display data from a text file in a JTable. You have you understand the structure of the data so that you can parse the data and create a table model that can access the data in a row/column format. Here is an example of a simple program that does this:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=315172

  • How to type the question in a .txt file

    im trying to create a java game like hangman if you heard of it. i noe that all the questions are needed to be type in a .txt file but i not sure how should it be type or in wad format. is there anyone out there who can help me with it? thank u

    You can type the questions on diffrent lines. Then using io you can use the InputStream.readLine() function to get each question individually.
    Why dont you try using JDBC for the same?
    http://www.thejavahub.com - Java Applications, Applets, Servlets, Code, Tutorial, Jobs, Articles and more. Register Now.

  • How to save the time to a .txt file and retrive it back as time?

    I have to save the time [hour:minute:second] and the date [date:month:year] to a .txt file. I am using the Calendar API to set the time and date as below
    FileOutputStream fileStream = new FileOutputStream ("what.txt");
    PrintWriter pw=new PrintWriter(fileStream, true);
    Calendar curDate = Calendar.getInstance();
    System.out.print(curDate.get(Calendar.DATE)+":");
    System.out.print(months[curDate.get(Calendar.MONTH)]+":");
    System.out.print(curDate.get(Calendar.YEAR));
    pw.println(curDate);
    I'll have to retrive these data back to use it to set timer
    timer = new Timer();
    timer.schedule(new RemindTask(), time);
    I try to retrive the data and use the Calendar API to that data by using the below program.
    I get the error as :
    C:\t\Retrivedate.java:41: int cannot be dereferenced
    System.out.print(t.get(Calendar.DATE)+":");
    How can I solve this so that I can use Calendar API on my retrived data?
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    class Test {
    public static void main(String args[]) {
    try {
    File inputFile = new File("what.txt");
    FileReader in = new FileReader("what.txt");
    int t;
    char[] tmp = new char[100];
    int cnt = in.read(tmp);
    String tm="";
    for (int j=0;j<cnt;j++)
    { tm+=tmp[j];
    try {
    t=Integer.parseInt(tm,10);
    catch (NumberFormatException exception) {}
    System.out.println("jika "+tm);
    Calendar curDate = Calendar.getInstance();
    String months[]={
    "Jan","Feb","Mar","Apr",
    "May","June","July","Aug",
    "Sept","Oct","Nov","Dec"};
    Date time1 = curDate.getTime();
    System.out.print(" \n"+time1.getHours());
    System.out.print(":"+time1.getMinutes());
    System.out.println(":"+time1.getSeconds());
    System.out.print(t.get(Calendar.DATE)+":");
    System.out.print(months[t.get(Calendar.MONTH)]+":");
    System.out.print(t.get(Calendar.YEAR));
    in.close(); }
    catch (IOException ex) {
    System.out.println("IOException:"+ex.toString()); }

    These lines do not make sense:
    System.out.print(t.get(Calendar.DATE)+":");
    System.out.print(months[t.get(Calendar.MONTH)]+":");
    System.out.print(t.get(Calendar.YEAR));
    1. t is an integer, it does not have any methods.
    2. It's a bad idea to use char[] to retrive the date. You should use readLine() method to retrieve the whole date string, say "10/23/2001" (certainly you can have hours, minutes, seconds, etc.). Then you need to use SimpleDateFormat class to parse this string. SimpleDateFormat gives you everything to parse a date string in any format you want.
    PC

  • How to display Japanese fonts in a .txt file i received?

    I received an email attachment that is a .txt file.
    Some of it is in Japanese and some is in English.
    The Japanese text turns out to look like gibberish.... like this...
    Media Start Media End Duration Log Note
    01:17:12;18 01:17:20;26 00:00:08;09 DZÇÍÇÁÇÃÉCÉìÉåÉbÉgÇÇøÇÂÇ¡Ç∆âÒǡǃÇ≥ÅAÇ¢ÇÎÇÒÇ»É]Å[ÉìÇ÷ǢǡǃǛǃÇsÇÖÇíÇíÇÅÇâÇéÇ ÷LJǡÇ∆ãflÇ≠çsǡǃÇ≥ÅAÉwÉäÇÃñ≥ë éûä‘Çè≠Ç»Ç≠Ç∑ÇÈÅB
    01:17:25;21 01:17:30;21 00:00:05;01 â¥ÇÁÇ©ÇÁ3ÉÅÅ[É^Å[ÇÃÇ∆DZÇÎÇ≈äCÇ™ÉAÉâÉCÉîDžǻǡÇΩÇÊÅI
    01:17:32;10 01:17:36;20 00:00:04;11 ÉwÉäǙdžÇÈÅBëDǙdžÇÈÅBå„âΩÇ™ó~ǵǢÅH
    If i send this cut/paste back to the person who emailed it to me, they say it is displaying fine in Japanese.
    I have no idea how to make this text show up in Japanese.
    Thanks for any help.
    Brian

    You might try giving the file a ".txt" extension. Then drag it on top of your Safari icon in the dock, which should open it with Safari. Then, under "View", select a Japanese "Text Encoding". My guess is that this is Shift-JIS.
    I am assuming you have not removed Japanese fonts from your system.

Maybe you are looking for

  • Edit document that was converted from PDF to Word Doc.

    How do I edit a document that I converted from a PDF to a word document????? When I open my now "Word Document" it does not allow me to edit the text.

  • IPhoto app doesn't show any photos from my photos app

    I just upgraded my new iPad to iOS 6 beta. Maybe that's the problem but suddenly my iPhoto app doesn't show any photos at all. All the tabs (albums, photos, events, etc) are empty.  When I open the app it says "updating photo library" briefly, but th

  • Message F5201 not appearing

    Dear Friends, We have defined posting periods in OB52 Transaction, but user is able to make transaction in system in previous period than mentioned in System. i.e. system is not issuing message F5201 as an error message. Please suggest the solution f

  • Oracle SQL Tuning

    Hi, Can somebody explain me about the basics of tuning or any good resource online for absolute beginners. Concepts of Explain Plan, Hints, indexes etc... I ve come across some terminolgy like, Driving table, The order of the table in the from clause

  • Jsp & custom tag buffer problem

    Hi all, I have a tag that reads one of the txt file and renders the output on the JSP. The problem is, when I refresh the same page in it duplicates the output and append it to the previous output every time (mostly). I know there is no that there is