Finding A Piece Of Text Within A Text?

Hi.
I am trying to create a program to find a piece of text within a file (containing text). I know that my life could be made much easier if I had the util.java.regex package but it doesn't seem to import.
I am working on a Windows XP Platform.
I have tried the Hello World program which works fine but it is just trying to import this package...

I am trying to work through this slowly so that I can understand each stage... so where I have come upto now is why does the following code not compile. I am just interested in taking a .txt file at the standard input which is used to serach against an Actor's name that I specify in the next (argument?) line?
Thanks for all the help
My Code so far...
import java.io.*;
// This line always has to be put in
public class MyFirstFileReadingAppTwo
          // Main method
          public static void main (String args[])
          // Stream to read file
          System.out.print("Enter your filename: ");     
          BufferedReader br = new BufferedReader(new FileInputStream (System.in));
          String userName = null;
          try
          // Open the input stream
          String file = br.readLine();
          BufferedReader reader2 = new BufferedReader(new FileReader(file));
          // Read a line of text
               System.out.println(new
               ln(new (fin).readLine() );
          // Close our input stream
          fin.close();          
               // Catches any error conditions
               catch (IOException e)
               System.err.println ("Unable to read from file");
               System.exit(-1);
}

Similar Messages

  • I cannot copy a piece of text within my web cms, security prohibited

    when i open my cms fom the website, i like to copy a piece of text, but the warning comes, that the browser prohibited it seems to be a security issue .
    Pls help
    i just want to copy and paste within my cms.

    Let's start with something very basic, and that is, you do not need to use the paste button on most websites. The button just reads what is on your clipboard and sticks it into the form. You can do that yourself using Ctrl+v or right-click>Paste.
    For your security, I suggest using those standard Windows keyboard shortcuts (Ctrl+x cut, Ctrl+c copy, Ctrl+v paste) or the context menu.
    Occasionally you will find a paste button that runs a clean-up script or otherwise does something useful. That is where the (admittedly a bit complicated) instructions come in handy.
    To open your active profile folder, you can use:
    Help > Troubleshooting Information > "Show Folder" button
    Which help article are you using for the modifications?
    Finally, please be cautious in opening up your clipboard to sites. You may have stuff you copied from other pages or other programs that you do not want to share with most sites.

  • Getting the Physical Length of a Piece of Text (in mm etc.) in Javascript

    I'm trying to write a script in Indesign CS5 (Windows) that can measure the physical, 'rendered' length of two pieces of text of similar length (in mm etc.), calculate the average length of the two, and adjust the tracking/horizontal scale of one or both of the pieces of text so that the physical length of both texts are the same.
    I need a script because this task must be done thousands of time in a long document.
    I'm struggling to find a way to access the 'rendered' length of a piece of text in Javascript.
    I know among the attributes of a text box is whether the text has overrun. So I could copy the text to a special text-box, and use a for loop to reduce the dimentions of the text box, 1mm at a time, until the text box overruns, thus determining the length..
    I could also get the length of a rendered string using python with it's built in GUI toolkit Tkinter:
    http://stackoverflow.com/questions/2922295/calculating-the-pixel-size-of-a-string-with-pyt hon
    And then have an indesign script that takes some data from the python script and sets the tracking/horizontal in Indesign with some fudge factors.
    Both ideas seem like real kludges.
    Any other suggestions?
    Many thanks
    David

    You can simply iterate through each line in text to get the widest line. Something like this:
    Main();
    function Main() {
        var text = app.selection[0],
        minLength, maxLength, start, end;
        for (var i = 0; i < text.lines.length; i++) {
            start = text.lines[i].characters[0].horizontalOffset,
            end = text.lines[i].characters[text.lines[i].characters.length-1].horizontalOffset;
            if (minLength == undefined || start < minLength) {
                minLength = start;
            if (maxLength == undefined || end > maxLength) {
                maxLength = end;
        var length = maxLength - minLength;
        $.writeln(length);
    But this approach seems to be a little less precise than creating outlines since (I guess) it measures up to the beginning of the last character; discretionary hyphens, line brakes, etc. are not included into the measurement.

  • Use smart mailbox to find email with specific text in attached pdf

    Does anyone known if a smart mailbox can be created to find emails with specific text within a pdf attached document. I know that spotlight can do this and it works fine but it would suite me better to be able to do this in mail.

    After some digging, I found that Spotlight returns the pdf attachment (found within the library/mail/download folder), but not the actual email. The only time it returns the email is if the search text or numerics are coincidentally within the written contents or subject line.
    Yes, i have tried setting up smart mailbox search criteria using the entire message contents but this does not find emails where the text exist within the pdf.
    I've checked spotlight pref.'s and all categories are checked off.
    Essentally, i need the smartbox search criteria to return results where the search text is found within the pdf attachment if possible. If this is not possible, i'll continue using spotlight searches outside of mail.
    I appreciate any help you can offer.

  • Adapt a piece of text to a curved shape?

    Hi to all,
    i want to adapt a piece of text to a curved shape, you have
    some examples here:
    http://www.saveyourmovies.com/images/text/TextEffect_ReShape_001.gif
    Is it possible with FH MX 11? how can i do it?
    if it is not possible, do you know any app to do it?
    NOTE: im a mac user, but lets try it windows users.

    I made this example for you;
    http://img58.imageshack.us/img58/2480/testingtoolsgt4.jpg
    (if url is not working, erase all after .jpg)
    First type and make your curve, mark both and use Attach to
    Path
    Then you see some kerning faults that you can take care of, I
    didn´t, and after this you convert to paths
    If you can find an Xtra toolbar, you will probably have a few
    tools to distort with
    I used Fisheye Lens and then 3D Rotation after that
    If you then would like color fills, maybe gradients you can
    do it in one step, or ungroup and treat each letter as you like...
    Good luck!

  • Finding Headings and Link Text in MARS files

    Hi,
    I've been looking into the MARS package and have been able to
    extract some great information for my application to read from the
    underlying XML, but I'm stuck on a few key items. Does anyone know
    how to reliably and programmatically find the following items
    throughout a MARS package?
    - Headings
    - Hyperlink TEXT (I can get the Rect & Dest from the
    /page/#/pg.can file but not the text itself)
    - Tables & Graphics (where they start and end in the
    svg?)
    What I'm looking to do is basically build a big inventory of
    all these common objects from a .mars file and report them to the
    user. I'm just using DOM to read the XML/SVG files.
    Thanks!

    Hi,
    Sadly, there is probably no easy way to do the things you are
    asking. Mars files generated from PDF are reliant of the
    funadmental properties of PDF. Below I will discuss each of your
    points:
    Headings:
    Depending on the producing application and the settings used
    to convert to PDF, there might be some slightly more intelligent
    way to do this. A PDF can be "Tagged", such that it has a logical
    structure tree. If your sources are very similar in nature (i.e.
    same producer and same settings) and come from a producer that
    creates Tagged PDF, then it is possible you can use the logical
    structure to locate headings. However, if the PDF does not have
    this information, the only indication you have that a given block
    of text is a heading is that it is bigger than the rest of the text
    and perhaps begins with a number. If the PDF is Tagged, then look
    for a struct.xml file in the same location as the page. This
    references a marked content section in the SVG, which is a named
    group.
    Hyperlinks:
    Sadly, there is very little that can be done here. PDF
    represents links as rectangles on the page. There is no direct
    association with the text that the user sees as a link. In HTML
    links are described as anchors linking to another location with a
    specific piece of text representing them. In PDF, it is just a
    rectangular overlay on the page. Any change in color (or an
    underline perhaps) is a text property and not part of the link.
    This is for historical reasons in PDF and Mars does not currently
    try to reconcile these pieces of information.
    Tables & Graphics:
    Well, tables are hard. There is no "table" operator in PDF,
    so tables are created using paths to draw the lines and text
    operators to place the text inside the table. Again, if you have a
    Tagged PDF, it is quite possible that the table has been marked in
    the struct.xml and the content identified, but as above, this is
    highly dependent on the nature of the source that was used to
    generate the PDF. The same is true for graphics. Graphics created
    with paths and other drawing operators do not necessarily get
    grouped as such, but a Tagged PDF (and therefore a Tagged Mars
    file) might have them.
    Conclusion:
    So, to summarize the above, there are possibilities and if
    you have control over the sources, there is a chance that you can
    easily obtain the information you require. However, if you have a
    number of disparate sources, then I suspect there is no easy
    solution for you.
    If you have any more specific questions or more details of
    the nature of your sources, perhaps there might be something you
    can look for. Also, let me know if you need more information
    regarding our logical structure implementation in Mars. As always
    with PDF, you are restricted by the quality of your sources and
    third party PDF creation tools do not necessarily add all the
    information that you would require for what you need.
    Matthew

  • Find exact word in text file tht is present in an excel sheet

    Hi all,
    i want to find words in an text file.
    but the criteria is i want to search words which r already listed in another excel sheet and change the color of these word.
    i used FileInputStream
    and also BufferedInputStream
    cany anyone help me with this

    hi kajbj,
    can u plz tell me how to do in VBA then
    will find out the way to do in java
    Thanx

  • How to find out who's texting you from an iCloud email address?

    how to find out who's texting you from an icloud email address?

    OK after a bit of research I found a way to achieve this.
    I simply looked up the email address in ADUC, then did a search in SP with the display name. I could locate the list and manually confirm it was configured with the incoming email address I was looking for.
    I also found the below script on Stackoverflow, but got "The 'using' keyword is not supported in this version of the language." when I tried to run it. Any idea how to fix that? I'd like to have a script to link a library to an email address istead of the
    manual approach described above.
    http://stackoverflow.com/questions/4974110/sharepoint-how-do-i-find-a-mail-enabled-list-if-i-only-have-the-email
    $SiteCollection = ""
    $EmailAddress = "" # only the part before the @
    # Load SharePoint module if not done yet
    if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {Add-PSSnapin Microsoft.SharePoint.PowerShell;}
    cls
    using System;
    using Microsoft.SharePoint;
    namespace FindListByEmail
    class Program
    {a
    static void Main(string[] args)
    string siteUrl = $SiteCollection;
    string email = $EmailAddress;
    using (SPSite site = new SPSite(siteUrl))
    foreach (SPWeb web in site.AllWebs)
    try
    foreach (SPList list in web.Lists)
    if (list.CanReceiveEmail)
    if (list.EmailAlias != null && list.EmailAlias.Equals(email, StringComparison.InvariantCultureIgnoreCase))
    Console.WriteLine("The email belongs to list {0} in web {1}", list.Title, web.Url);
    Console.ReadLine();
    return;
    finally
    if (web != null)
    web.Dispose();

  • Returning a piece of text in a SELECT

    Hello!
    I'm doing a search in a table that has four fields:
    ID
    NAME varchar(128)
    TEXT1 varchar(500)
    TEXT2 varvhar(500)
    Well, I need to search for a word in fields TEXT1 and TEXT2. My
    first step is to do the following:
    SELECT ID,NAME
    FROM TABLE
    WHERE CONTAINS(TEXT1,'word',1) > 0
    AND CONTAINS(TEXT2,'word',2) > 0
    Well, til here is all ok, but now... I need something more
    difficult:
    I need to obtain for each ID, the piece (or the first piece) of
    text where 'word' was found on, considering that this word can
    be allocated in TEXT1 or in TEXT2.
    Thank you very much!!
    Carlos Moreno

    Carlos...
    I'm not familiar with the CONTAINS function, but I'll assume it
    returns a number greater than zero when the desired condition is
    met.
    The way your where clause is written, the result set will
    include only those rows from TABLE where 'word' is in BOTH TEXT1
    and TEXT2.
    I'm guessing about what you want, but here goes...
    SELECT id
         , name
         , CONCAT( DECODE( SIGN( CONTAINS(text1,'word',1) )
                         , 1, CONCAT( 'From text1: '
                                      SUBSTR( text1
                                      , 1
                                      , INSTR( text1
                                             , 'word'
                                             ) + 3
                 , DECODE( SIGN( CONTAINS(text2,'word',1) )
                   , 1, CONCAT( ' From text2: '
                                SUBSTR( text2
                                , 1
                                , INSTR( text1
                                       , 'word'
                                       ) + 3
                 ) AS text
      FROM table
    WHERE CONTAINS(text1,'word',1) > 0
       AND CONTAINS(text2,'word',2) > 0
         ;The column text should contain the contents of columns text1 and
    text2 up to 'word', prepended with the 'From text1;' and 'From
    test2:'
    If the AND in the where clause is replaced with and OR, then the
    parts of text1 and text2 will only be returned if the
    contain 'word'.
    I did not test this code.
    Good Luck...
    -

  • HT2476 How do I copy the names of files in a finder window to a text document?

    How do I copy the names of files in a finder window to a text document?

    If using Apple TextEdit Applications: Select all the files in the finder window, choose copy. Go to the TextEdit window and from the menu choose Edit then choose Paste and Match Style from the Edit drop down menu.

  • How to find out all the text elements in the report using Java?

    How to trace the contents of an rpt file?
    I am able to open the rpt file in my report viewer but can not trace it using the JAVA code.
    Actually, I need to find out all the text elements of rpt (Report) file and replace them with the contents of resource bundle.
    My Java code to open a report is given below:
    import com.crystaldecisions.reports.sdk.ISubreportClientDocument;
    import com.crystaldecisions.reports.sdk.ParameterFieldController;
    import com.crystaldecisions.reports.sdk.ReportClientDocument;
    import com.crystaldecisions.sdk.occa.report.data.ConnectionInfo;
    import com.crystaldecisions.sdk.occa.report.data.ConnectionInfos;
    import com.crystaldecisions.sdk.occa.report.data.Fields;
    import com.crystaldecisions.sdk.occa.report.data.IConnectionInfo;
    import com.crystaldecisions.sdk.occa.report.data.ParameterField;
    import com.crystaldecisions.sdk.occa.report.data.ParameterFieldDiscreteValue;
    import com.crystaldecisions.sdk.occa.report.data.Values;
    import com.crystaldecisions.sdk.occa.report.lib.IStrings;
    import com.crystaldecisions.sdk.occa.report.lib.PropertyBag;
    import com.crystaldecisions.sdk.occa.report.lib.PropertyBagHelper;
    import com.crystaldecisions.sdk.occa.report.lib.ReportSDKException;
    import com.crystaldecisions.sdk.occa.report.reportsource.IReportSource;
    public String viewRpt()
                   //1.) Setting Database Infos
                            IConnectionInfo iConnectionInfoObj=setDatabaseConnectionInfos();
                   //2.) Setting Report Path
                   String reportPath=u201DE:
    was60
    rptFilesLocation
    u201D;
                   reportPath=(reportPath!=null)?                                             reportPath:AppConstants.CONSTANTS.BLANK;
                   String reportName="report1.rpt";
                   String reportFullPath = reportPath +   rptName;
                 //3.) Setting Report Source
                             ReportClientDocument reportClientDoc = new ReportClientDocument();
                                              reportClientDoc.open(reportPath, 0);
                  IReportSource reportSource = reportClientDoc.getReportSource();
                  setReportSource(reportSource);
                  reportClientDoc.close();
              //4.) Setting the Fields Starts
              setFieldsCrystal(null);
              Fields fields = new Fields();
              ParameterField pfield1 = new ParameterField();
              Values vals1 = new Values();
              ParameterFieldDiscreteValue pfieldDV1 = new ParameterFieldDiscreteValue();
              pfield1.setName("@parameter1");
              pfieldDV1.setValue(u201Cvalue1u201D);
              vals1.add(pfieldDV1);
              pfield1.setCurrentValues(vals1);
              fields.add(pfield1);
              pfield1 = new ParameterField();
              vals1 = new Values();
              pfieldDV1 = new ParameterFieldDiscreteValue();
              pfield1.setName("@parameter2");
              pfieldDV1.setValue(u201Cvalue2u201D);
              vals1.add(pfieldDV1);
              pfield1.setCurrentValues(vals1);
              fields.add(pfield1);
              setFieldsCrystal(fields);
              //Setting the Fields Ends
    The sample jsp code to view the report is as follows:
    <%@taglib uri="http://www.businessobjects.com/jsf/crystalreportsviewers"
         prefix="bocrv"%>
    <bocrv:reportPageViewer viewerName="CrystalViewer"
                                                 reportSource="#{CrystalReportBeanObject.reportSource}"
                                                 displayToolbarRefreshButton="false"
                                                 allowDatabaseLogonPrompting="false"
                                                 allowParameterPrompting="false"
                                                 databaseLogonInfos="#{CrystalReportBeanObject.connectionInfosCrystal}"
                                                 parameterFields="#{CrystalReportBeanObject.fieldsCrystal}"
                                                 displayGroupTree="false" displayToolbarLogo="false"
                                                 displayToolbarToggleTreeButton="false"
                                                 enablePageToGrow="false" height="540"
                                                 zoomPercentage="100" width="750"
                                                 allowDrillDown="false"
                                                 displayToolbarPrintButton="true"
                                                 printMode="PDF"
                                                 ></bocrv:reportPageViewer>
    Edited by: JayKumarSharma on Mar 23, 2011 12:42 PM

    This is how you retrieve all the text fields in the reort:
    ReportObjects reportObjects = (ITextObject) oReportClientDocument.getReportDefController().getReportObjectController().getReportObjectsByKind(ReportObjectKind.text);
    for(int i=0; i< reportObjects.size();i++)
    ITextObject textObject = (ITextObject)reportObjects.get(i);
    // use ReportObjectController to modify the text object.
    If you want to modify the contents of the text element, you can do it as follows:
    TextObject oTextObject = new TextObject();
    Paragraphs oParagraphs = new Paragraphs();
    Paragraph oParagraph = new Paragraph();
    ParagraphElements oParagraphElements = new ParagraphElements();
    ParagraphTextElement oParagraphTextElement = new ParagraphTextElement();
    oParagraphTextElement.setText("This is the new text field");
    oParagraphTextElement.setKind(ParagraphElementKind.text);
    oReportClientDocument.getReportDefController().getReportObjectController().modify(textObject, oTextObject);
    oReportClientDocument.save();

  • The Find function (Ctrl+F), mis-finds the desired simple text in Acrobat Standard, but works fine in Reader

    Adobe Acrobat X 10.1.13, Win 7 64bit, 
    The Find function (Ctrl+F), mis-finds the desired simple text. 
    This is not a scanned document.  When I search for some word that DOES exist in the document, Acrobat will highlight text that does not match at all and which does NOT contain the word.  If I select the actual word, copy and past the text, I get the selected text accurately, but when I paste the same selected text into the Find box to search for it, Acrobat still mis-finds. 
    HOWEVER, I can open the very same .PDF file in Acrobat Reader X and do not have the same problem - Find works correctly in Reader with the same .PDF. 
    What is going on?!  Both Acrobat standard, and Reader report that they are up to date.   Please help.

    Can you try rasterizing (converting the document to tiff/bmp) and then importing those image files (tiff/bmp) back in Acrobat.
    This would allow document to be re-OCRed and you will be able to search text in it. You can use lossless export/import settings to preserve the quality of ducment.
    For exporting the file:
    1: Go to File > Save As Other > Image > Tiff.
    2: Click on Settings button in the Save As Dialog and set the file settings as ZIP for Monochrome, Grayscale and Color.
    Now for importing the files back:
    1: Press Ctrl + K
    2: In the Preferences dialog, select Convert To PDF option in Categories.
    3: Choose tiff or bmp (as per the format used while exporting) and un-check Scan Optimization and OCR.
    4: Set Color and Grayscale to Zip and Monochrome to CCITT G4.
    5: Save the settings.
    6: Now import all the pages in Acrobat.
    7: You can use Combine Files feature to merge all the image files.

  • I accidently cut a piece of text out of a mail message

    I accidently cut a piece of text out of a mail message the copied a different piece of text with out thinking is thee any way to get the first piece of cut text back?

    Welcome to Apple Discussions!
    Mail supports multiple undos. Keep on undoing from the Edit menu! Not sure how far back that undo buffer is, but keep on trying. If it doesn't work, test it so you know for the future.

  • Adding a rectangle behind every piece of text in CS5

    Hi,
    I am making a series of map tiles (30) and would like to have a white rectangle behind every peice of black text in a certain layer. I know how to add a rectangle and position it behind the text, but want to avoid this repetive process.
    I understand that each piece of text has a 'bounding box' - is there a way to add a fill to this box for all text at once?
    Thanks,
    Mike.

    Mike,
    You may:
    1) Select all the instances of Type,
    2) In the Appearance palette flyout tick Add New Fill, drag it down below Characters, and change its colour to white,
    3) With the white Fill selected, Effect>Convert to Shape with the desired oversize.
    Edit: Once again, hi Kurt.

  • [cs3][JS]Find Enter with no text in Layout

    Hi,
       I need to find enter with no text(idle) in a Layout.I have used the following code.
            app.findGrepPreferences = NothingEnum.nothing;
            app.changeGrepPreferences = NothingEnum.nothing;
            app.findGrepPreferences.findWhat ="\n";
            app.findChangeGrepOptions.includeFootnotes = false;
            app.findChangeGrepOptions.includeHiddenLayers = false;
            app.findChangeGrepOptions.includeLockedLayersForFind = false;
            app.findChangeGrepOptions.includeLockedStoriesForFind = false;
            app.findChangeGrepOptions.includeMasterPages = false;
            var myFoundItems=new Array;
            myFoundItems=app.activeDocument.findGrep();
            var len=myFoundItems.length;
            alert(len);
    I don't know whether my approach is correct or not? Please suggest me.
    Regards
    Kumar

    hi Kumar,
    you need to find "double enter" and then process second paragraph in each found result - but you need to process found items backward
    or if you want to find empty TextFrames - you wont find them in this way - becuase empty TFs are empty no enter or any other characters
    robin
    www.adobescripts.co.uk

Maybe you are looking for

  • Itunes wont open on Windows 7. Have tried EVERYTHING?

    My name is Hunter and i have tryed everything to open up my Itunes. I have Windows 7 on a HP Probook 4425s and i have been all over the web looking for help. I have tried uninstalling and repairing multiple times and still nothing. Any help would be

  • Aduio problem with DVX Cameras

    Hi All. I am having trouble getting the audio from the DVX to come through VC3. I'm on Vista. NOT XP..is XP better for using VC2? I have selected the audio and video as audio 1/video1 and it sees the panasonic dvx. I get the video fine, and upon rest

  • Withholding infotype 210 using check date

    Hi Currently USTAX using Checkdate to determine IT0210 information ,how do we change this to period begindate/end date. example we have an employee who wants to change the excemptios based on apyperiod but system taking check date instead of period b

  • How to force use of new JDBC MySQL Driver?

    Hi Everyone, In my local JDK(1.6) I have : "..\jdk\jre\lib\ext\mysql-connector-java-5.0.6-bin.jar" in my classpath. Under Netbeans, I have added Version 5.1.6 to my libraries, and added the library to my project. When running the preject locally with

  • I cannot connect facetime

    I cannot connect facetime, I already have apple ID but everytime I try to sign in, it doesn't work.