Find text from a file and set it as a variable in applescript?

I am trying to build a script that sends me updates and notifications from cex.io. Please keep on reading below, so I may guide you until the point I have trouble with.
The first simple script in this operation goes to cex.io's trading page for BTC/GHS. It records ands saves the text to a file every 4 seconds. It works great. It doesn't need to have safari refresh because the site pushes info to the browser live.
  repeat
          set the webpage_content to ""
          tell application "Safari" to set the webpage_content to the text of document 1
          set theText to webpage_content
          set a to "Macintosh HD:Users:PRIVATE:Desktop:CEX:"
          set theFile to (open for access file ((a) & "CEXRaw") with write permission)
          write theText to theFile
          close access theFile
          delay 4
  end repeat
And it returns this from the site to this main file every 4 seconds: (note I cut off a chunk from the bottom and the top of the file, because they are unimportant)
    GHS:
    0.05233439
    BTC:
    0.00000223
    NMC:
    0.00002939
    LTC:
    0.00000000
    GHS/BTC
    0.02362958 LTC/BTC
    0.02438131 NMC/BTC
    0.00597565 GHS/NMC
    3.96951800 BF1/BTC
    1.67000000 Fund Account
    GHS/BTC
    Last price:
    0.02362958
    Daily change:
    -0.00018042
    Today's open:
    0.02381000
    24h volume:
    73812.35539255
I now need an applescript to read that file, and return wanted values. But I'm lost on how to write it.
It needs to find the number under BTC, and set it as a variable.
It needs to find the number under GHS, and set it as a variable.
It needs to find the number under Last Price, and set it as a variable.
If anyone could script that really quick for me, or tell me how to do it, that would be amazing. Thank you so much!

Couldn't tell if you had any whitespace in the lines (i.e. is there a space before or after GHS:), so I used contains, not is.  Also, if you have a line such as GHS/BTC with a colon GHS/BTC:  then it will also fail (as contains "BTC:" would be true for BTC: and GHS/BTC:)
However, this will give you some guidance:
set a to "Macintosh HD:Users:PRIVATE:Desktop:CEX:CEXRaw"
set x to 0
set Names to paragraphs of (read file a)
repeat with nextLine in Names
          set x to x + 1
          if nextLine contains "BTC:" then
                    set BTC to item (x + 1) of Names
          else if nextLine contains "GHS:" then
                    set GHS to item (x + 1) of Names
          else if nextLine contains "Last Price:" then
                    set lastPrice to item (x + 1) of Names
          end if
end repeat

Similar Messages

  • Reading data From XML file and setting into ViewObject to Pouplate ADF UI

    Hi,
    I have following requirement.
    I would like to read data from XML file and populate the data in ViewObject so that the data can be displayed in the ADF UI.
    Also when user modifies the data in the ADF UI, it should be modified back into to ViewObject.
    Here is an example - XML file contains Book Title and Author. I would like to read Book Title and Author from XML file and set it into ViewObject Attribute and then display Book title and Author in ADF UI page. Also when user modifies Book title and Author, I would like to store it back in View Object.
    Please help me with this requirement and let me know if any solution exist in ADF, for populating the ADF UI screen fields with external XML file data.
    Thanks

    Read chapter 42 http://download.oracle.com/docs/cd/E16162_01/web.1112/e16182/bcadvvo.htm of the fusion developer guide
    Section 42.7, "Reading and Writing XML"
    Section 42.8, "Using Programmatic View Objects for Alternative Data Sources"
    Timo

  • How to add text in .ai file and  set position, font, size and colour

    I want to place multiple lines of of text (individually) into .ai file and set size, font, colour and position for each.
    Preferably text should have origin in a single point (rather than be framed)
    Hope anyone can help me out.
    Thank you in advance.

    Here's what's in the Scripting Reference
    Creating and modifying text frames
    // Creates a document with text frames displaying path, area and point
    // text, changes the content of each frame then deletes the 2nd frame
    // create a new document
    var docRef = documents.add();
    // create 3 new textFrames (area, line, point)
    // Area Text
    var rectRef = docRef.pathItems.rectangle(700, 50, 100, 100);
    var areaTextRef = docRef.textFrames.areaText(rectRef);
    areaTextRef.contents = "TextFrame #1";
    areaTextRef.selected = true;
    // Line Text
    var lineRef = docRef.pathItems.add();
    lineRef.setEntirePath( Array(Array(200, 700), Array(300, 550) ) );
    var pathTextRef = docRef.textFrames.pathText(lineRef);
    pathTextRef.contents = "TextFrame #2";
    pathTextRef.selected = true;
    // Point Text
    var pointTextRef = docRef.textFrames.add();
    pointTextRef.contents = "TextFrame #3";
    pointTextRef.top = 700;
    pointTextRef.left = 400;
    pointTextRef.selected = true;
    redraw();
    // count the TextFrames
    var iCount = docRef.textFrames.length;
    var sText = "There are " + iCount + " TextFrames.\r"
    sText += "Changing contents of each TextFrame.";
    // change the content of each
    docRef.textFrames[0].contents = "Area TextFrame.";
    docRef.textFrames[1].contents = "Path TextFrame.";
    docRef.textFrames[2].contents = "Point TextFrame.";
    redraw();
    docRef.textFrames[1].remove();
    redraw();
    // count again
    var iCount = docRef.textFrames.length;
    Your are looking stuff with the pointTextRef.

  • Why can I not copy text from a file and paste into "File Name" when saving?

    I thought I used to do this but I cannot copy a string of text from within AI (CS5, CS6 or CC) then "save as" and paste into the "file name" field. Why would this be?
    This proceedure works fine in Photoshop.
    Mac OSX 10.7.5.

    I am copying the characters not the object. Something seems to have changed at the system level. I can paste the text to other applications (Skype, Word, etc.) but not the "Save" dialog. I have been pasting the text to a Skype message window and re-copying. Then it will paste into the save dialog. Weird.
    I see you are on 10.6.8. Maybe it's a system difference.

  • Hello i need a help about script to export translatable text strings from ai files and import them back

    Hello i need a help about script to export translatable text strings from ai files and import them back after editing, thanks in advance

    Lanny -
    Thank you for taking the time to help with this problem. Can I just say however that as someone who has posted a first comment here and quite clearly never used a forum like this before, your comment unfortunately comes across as very excluding. It makes me feel there are a set of unwritten rules that I should know, and that I don't know them shows that the forum is not for me. In short, it's exactly the kind of response that stops people like me using forums like this.
    I'm sure it's not intended to be received like this and I am sure that the way you have responded is quite normal in the rules of a forum like this. However, it is not normal for those of us who aren't familiar with forums and who only encounter them when they have a genuine problem. This is why I hope it is helpful to respond in full.
    The reason I posted here is as follows. I was directed here by the apple support website. The original comment seemed to be the only one I could find which referred to my issue. As there is no obvious guidance on how to post on a forum like this it seemed perfectly reasonable to try and join in a conversation which might solve more than one problem at once.
    Bee's reply however is both helpful and warm. This could in fact be a template for how new members should be welcomed and inducted into the rules of the forum in a friendly and inclusive way. Thank you very much indeed Bee!

  • How can I input read a line from a file and output it into the screen?

    How can I input read a line from a file and output it into the screen?
    If I have a file contains html code and I only want the URL, for example, www24.brinkster.com how can I read that into the buffer and write the output into the screen that using Java?
    Any help will be appreciate!
    ======START FILE default.html ========
    <html>
    <body>
    <br><br>
    <center>
    <font size=4 face=arial color=#336699>
    <b>Welcome to a DerekTran's Website!</b><br>
    Underconstructions.... <br>
    </font> </center>
    <font size=3 face=arial color=black> <br>
    Hello,<br>
    <br>
    I've been using the PWS to run the website on NT workstation 4.0. It was working
    fine. <br>
    The URL should be as below: <br>
    http://127.0.0.1/index.htm or http://localhost/index.htm
    <p>And suddently, it stops working, it can't find the connection. I tried to figure
    out what's going on, but still <font color="#FF0000">NO CLUES</font>. Does anyone
    know what's going on? Please see the link for more.... I believe that I setup
    everything correctly and the bugs still flying in the server.... <br>
    Thank you for your help.</P>
    </font>
    <p><font size=3 face=arial color=black>PeerWebServer.doc
    <br>
    <p><font size=3 face=arial color=black>CannotFindServer.doc
    <br>
    <p><font size=3 face=arial color=black>HOSTS file is not found
    <br>
    <p><font size=3 face=arial color=black>LMHOSTS file
    <br>
    <p><font size=3 face=arial color=black>How to Setup PWS on NT
    <BR>
    <p><font size=3 face=arial color=black>Issdmin doc</BR>
    Please be patient while the document is download....</font>
    <font size=3 face=arial color=black><br>If you have any ideas please drop me a
    few words at [email protected] </font><br>
    <br>
    <br>
    </p>
    <p><!--#include file="Hits.asp"--> </p>
    </body>
    </html>
    ========= END OF FILE ===============

    Hi!
    This is a possible solution to your problem.
    import java.io.*;
    class AddressExtractor {
         public static void main(String args[]) throws IOException{
              //retrieve the commandline parameters
              String fileName = "default.html";
              if (args.length != 0)      fileName =args[0];
               else {
                   System.out.println("Usage : java AddressExtractor <htmlfile>");
                   System.exit(0);
              BufferedReader in = new BufferedReader(new FileReader(new File(fileName)));
              StreamTokenizer st = new StreamTokenizer(in);
              st.lowerCaseMode(true);
              st.wordChars('/','/'); //include '/' chars as part of token
              st.wordChars(':',':'); //include ':' chars as part of token
              st.quoteChar('\"'); //set the " quote char
              int i;
              while (st.ttype != StreamTokenizer.TT_EOF) {
                   i = st.nextToken();
                   if (st.ttype == StreamTokenizer.TT_WORD) {          
                        if (st.sval.equals("href")) {               
                             i = st.nextToken(); //the next token (assumed) is the  '=' sign
                             i = st.nextToken(); //then after it is the href value.               
                             getURL(st.sval); //retrieve address
              in.close();
         static void getURL(String s) {     
              //Check string if it has http:// and truncate if it does
              if (s.indexOf("http://") >  -1) {
                   s = s.substring(s.indexOf("http://") + 7, s.length());
              //check if not mailto: do not print otherwise
              if (s.indexOf("mailto:") != -1) return;
              //printout anything after http:// and the next '/'
              //if no '/' then print all
                   if (s.indexOf('/') > -1) {
                        System.out.println(s.substring(0, s.indexOf('/')));
                   } else System.out.println(s);
    }Hope this helps. I used static methods instead of encapsulating everyting into a class.

  • Reading long text from excel file to an internal table

    Hi
    Can any body tell me how to read long text from excel file to an internal table.
    When i am using this FM KCD_EXCEL_OLE_TO_INT_CONVERT then it is reading only 32 characters from each cell.
    But in my excel sheet in one of the cell has very long text which i need to upload into a internal table.
    may i know which FM or what logic i need to use for this problem.
    Regards

    Hi,
    Here is an example program.  It will upload an Excel file with two columns.  You could also assign the Excel structure dynamically, but I wanted to keep the example simple.  The main point is that the internal table (it_excel in this example) must match the Excel structure that you want to convert.
    Remember, this is just an example to help you figure out how to properly use the technique.  It will certainly need to be modified to fit your requirements, and as always there may be a better way to get the Excel converted... this is just one possibility that has worked for me in the past.
    *& Report  zexcel_upload_test                            *
    REPORT  zexcel_upload_test.
    TYPE-POOLS: truxs.
    TYPES: BEGIN OF ty_excel,
             col_a(10) TYPE n,
             col_b(35) TYPE c,
           END OF ty_excel.
    DATA: l_data_tab         TYPE TABLE OF string,
          l_text_data        TYPE truxs_t_text_data,
          l_gui_filename     TYPE string,
          it_excel           TYPE TABLE OF ty_excel.
    FIELD-SYMBOLS: <wa_excel>  TYPE ty_excel.
    PARAMETERS: p_file TYPE rlgrap-filename.
    * Pass the file name in the correct format
    l_gui_filename = p_file.
    * Upload data from PC
    CALL METHOD cl_gui_frontend_services=>gui_upload
      EXPORTING
        filename                = l_gui_filename
        filetype                = 'ASC'
        has_field_separator     = 'X'
      CHANGING
        data_tab                = l_data_tab
      EXCEPTIONS
        file_open_error         = 1
        file_read_error         = 2
        no_batch                = 3
        gui_refuse_filetransfer = 4
        invalid_type            = 5
        no_authority            = 6
        unknown_error           = 7
        bad_data_format         = 8
        header_not_allowed      = 9
        separator_not_allowed   = 10
        header_too_long         = 11
        unknown_dp_error        = 12
        access_denied           = 13
        dp_out_of_memory        = 14
        disk_full               = 15
        dp_timeout              = 16
        OTHERS                  = 17.
    IF sy-subrc <> 0.
    *   MESSAGE ...
      EXIT.
    ENDIF.
    * Convert from Excel into the appropriate itab
    l_text_data[] = l_data_tab[].
    CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
      EXPORTING
        i_field_seperator    = 'X'
        i_tab_raw_data       = l_text_data
        i_filename           = p_file
      TABLES
        i_tab_converted_data = it_excel
      EXCEPTIONS
        conversion_failed    = 1
        OTHERS               = 2.
    IF sy-subrc <> 0.
    *   MESSAGE ...
      EXIT.
    ENDIF.
    LOOP AT it_excel ASSIGNING <wa_excel>.
    *  Do something here...
    ENDLOOP.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      PERFORM filename_get CHANGING p_file.
    *       FORM filename_get                                             *
    FORM filename_get CHANGING p_in_file TYPE rlgrap-filename.
      DATA: l_in_file  TYPE string,
            l_filetab  TYPE filetable,
            wa_filetab TYPE LINE OF filetable,
            l_rc       TYPE i,
            l_action   TYPE i,
            l_init_dir TYPE string.
    * Set the initial directory to whatever you want it to be
      l_init_dir = 'C:\'.
    * Call the file open dialog without multiselect
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          window_title            = 'Load file'
          default_extension       = '.XLS'
          default_filename        = l_in_file
          initial_directory       = l_init_dir
          multiselection          = 'X'
        CHANGING
          file_table              = l_filetab
          rc                      = l_rc
          user_action             = l_action
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          OTHERS                  = 4.
      IF sy-subrc <> 0.
        REFRESH l_filetab.
      ENDIF.
    * Read the selected filename
      READ TABLE l_filetab INTO wa_filetab INDEX 1.
      IF sy-subrc = 0.
        p_in_file = wa_filetab-filename.
      ENDIF.
    ENDFORM.                    " filename_get
    Regards,
    Jamie

  • VB Script to find the last modified file and time in a directory

    Hi,
    I am new to VB script i need a script to find the latest modifed file and last modifed time in a directory(Contains  folders and sub folders inside it). it has to go through all the folders and get the latest file and last modifed time.

    Thanks it worked for me Get-ChildItem C:\Users\sujith.reddy.komma\Desktop\Suj1\* -recurse |?{-not $_.PsIsContainer} |Sort LastWriteTime -desc | select -first 1 now in my script i have hard coded the directory i need to run this script in different
    servers from one location i will put all the different paths in one text file and ineed to pass them to this script can you help me with this?
    Essentially you are incrementally asking us to write each line for you.  I recommend freeing yourself of this misery and leraning PowerShell.  THe answers to all of your questions are learned in the first few hours of study.
    Start here:
    http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx
    ¯\_(ツ)_/¯

  • I cant use the highlight, underline, or strikethrough function in a specific pdf file. The file isnt locked. I used to highlight texts from that file before the latest update. The problem occurs only with that file. Urgent need. Please help. Thanks!

    i cant use the highlight, underline, or strikethrough function in a specific pdf file. The file isnt locked. I used to highlight texts from that file before the latest update. The problem occurs only with that file. Urgent need. Please help. Thanks!

    Chester31,
    Thank you very much for sharing your file with us!  Now that we are able to reproduce the problem at our end, you may stop sharing the file on Acrobat.com.
    Do you know when this problem (for not being able to add new highlight/strikeout/underline) has started?  Did you update your iOS from 7.x to 8.0 recently?
    We will continue investigating the problem and let you know what we find.
    Thank you again for your help.

  • Does IBR support to extract text from office files

    hi Experts,
    Can we use IBR to extract word/excel/ppt content to a text file? where is doc for this function?
    Best regards

    Hi ,
    Extraction of text based on some rules ?Is that what you are looking for ? Is it for searching on those specific set of texts from the file ? If yes , then you have Oracle Text search feature which would do that .
    If it is to populate some metadata with those extracted texts , then it would be Content Categorizer component . For details on this component and it's functionality please go through the following documentation : http://docs.oracle.com/cd/E14571_01/doc.1111/e10978/c11_content_categorizer.htm#sthref1210
    In either cases , IBR is not the actual engine which would do this . It is solely used for document conversion . \
    Hope this helps .
    Thanks,
    Srinath

  • How to  read from excel file and write it using implicit jsp out object

    our code is as below:Please give us proper solution.
    we are reading from Excel file and writing in dynamicaly generated Excel file.it is writing but not as original excel sheet.we are using response.setContentType and response.setHeader for generating pop up for saveing the original file in to dynamically generated Excel file.
    <%@ page contentType="application/vnd.ms-excel" %>
    <%     
         //String dLoadFile = (String)request.getParameter("jspname1");
         String dLoadFile = "c:/purge_trns_nav.xls" ;
         File f = new File(dLoadFile);
         //set the content type(can be excel/word/powerpoint etc..)
         response.setContentType ("application/msexcel");
         //get the file name
         String name = f.getName().substring(f.getName().lastIndexOf("/") + 1,f.getName().length());
         //set the header and also the Name by which user will be prompted to save
         response.setHeader ("Content-Disposition", "attachment;     filename="+name);
         //OPen an input stream to the file and post the file contents thru the
         //servlet output stream to the client m/c
              FileInputStream in = new FileInputStream(f);
              //ServletOutputStream outs = response.getOutputStream();
              int bit = 10;
              int i = 0;
              try {
                        while (bit >= 0) {
                        bit = in.read();
                        out.write(bit) ;
    } catch (IOException ioe) { ioe.printStackTrace(System.out); }
              out.flush();
    out.close();
    in.close();     
    %>

    If you want to copy files as fast as possible, without processing them (as the DOS "copy" or the Unix "cp" command), you can try the java.nio.channels package.
    import java.nio.*;
    import java.nio.channels.*;
    import java.io.*;
    import java.util.*;
    import java.text.*;
    class Kopy {
         * @param args [0] = source filename
         *        args [1] = destination filename
        public static void main(String[] args) throws Exception {
            if (args.length != 2) {
                System.err.println ("Syntax: java -cp . Kopy source destination");
                System.exit(1);
            File in = new File(args[0]);
            long fileLength = in.length();
            long t = System.currentTimeMillis();
            FileInputStream fis = new FileInputStream (in);
            FileOutputStream fos = new FileOutputStream (args[1]);
            FileChannel fci = fis.getChannel();
            FileChannel fco = fos.getChannel();
            fco.transferFrom(fci, 0, fileLength);
            fis.close();
            fos.close();
            t = System.currentTimeMillis() - t;
            NumberFormat nf = new DecimalFormat("#,##0.00");
            System.out.print (nf.format(fileLength/1024.0) + "kB copied");
            if (t > 0) {
                System.out.println (" in " + t + "ms: " + nf.format(fileLength / 1.024 / t) + " kB/s");
    }

  • How to get Mountain Lion Spotlight to find text in CSV files?

    Does anyone know how to get Mountain Lion Spotlight to find text in CSV Files? Spotlight worked flawlessly with Snow Leopard on my last MAC but with Mountain Lion it doesn't recognize CSV Files. I have researched this extensively and haven't found any solution but I really believe there must be many others who have the same problem. I even contacted Apple's Genius Bar which was of no help whatsoever, they couldn't even tell me why Spotlight wasn't finding text in CSV Files, i.e., function dropped by Apple, bug, etc.
    Thru research I found that if the CSV Files are converted to 'Plain Text Files' Spotlight will find text inside of the files but I typically save my spreadsheets as CSV Files and don't want to have to convert them to Plain Text Files just so Spotlight will search them.
    I appreciate any help you can give.
    Joel

    I should have mentioned earlier that I do NOT have any exclusions set under the Spotlight Privacy tab, however, I did move one of the folders that contains CSV Files in then back out of the Privacy tab to try and get Spotlight to index the folder, but to no avail.
    I have a second Admin account and tried to find text in CSV Files while in that account, again to no avail. I also tried upgrading to Mountain Lion 10.8.4 to see if it might fix the problem, but no soap.
    Below is a screenshot of the Systems Preferences/Library/Spotlight/RichText.mdimporter/ file and I don't even see where Spotlight is setup to find CSV Files on my computer, very confusing but thanks again for your input.

  • How to load some text from properties file ?

    Hi again,
    problem is i dont know how can i load a text from properties file like #{xxx['key']} in managed bean, i tried to find some solution but havent seen this kind of use this file in java code. Is it supposed to work only for labels in jspx pages ?
    thanks for help ...

    Hi,
    a managed bean is nothing special from any other Java file. However, if you look at SRDemo, you find a nice way of using the same message bundle that you use on the page
    See the messageFromBundle() method in the JSFUtils class of the UserInterface project
    Frank
    P.s. You can download and setup SRDemo from JDeveloper help--> check for updates

  • How can I read only a line of text from a file, line by line using Scanner?

    Here's the code I currently have for a program that finds a keyword from numerous files and prints every line in every file that has that keyword. The keyword is indicated by the first parameter in a command line and the files are every parameter after that. Right now, with the code I have, the program will not print multiple lines of each file if they contain the keyword. I am trying to solve this problem by figuring out a way to have a loop continue until an \n EOL character is found. I am not sure how to do this though. Here's the portion of code that I would like to change to do this. I need to add a condition somewhere after in.hasNext() I think to stop when it it hits a /n.:
    while (in.hasNext()) {
                        count++;
                        String nextWord = in.next();
                        lineOfText.add(nextWord);
                        if (nextWord.equals(keyword)) {
                            flag = true;
    import java.util.Scanner;
    import java.io.IOException;
    import java.io.FileNotFoundException;
    import java.io.FileInputStream;
    import java.io.PrintWriter;
    import java.util.ArrayList;
    public class Find {
        static ArrayList<String> lineOfText = new ArrayList<String>();
        static boolean flag = false;
        public static void main(String args[]) {
                   run(args);
        public static void run(String args[]) {
            try {
                PrintWriter out = new PrintWriter("output.txt");
                String keyword = args[0];
                for (int i = 1; i < args.length; i++) {
                    Scanner in = new Scanner(new FileInputStream(args));
    int count = 0;
    while (in.hasNext()) {
    count++;
    String nextWord = in.next();
    lineOfText.add(nextWord);
    if (nextWord.equals(keyword)) {
    flag = true;
    if (flag == true) {
    System.out.print(args[i] + ": " );
    out.print(args[i] + ": " );
    for (String s : lineOfText) {
    System.out.print(s + " ");
    out.print(s + " ");
    System.out.print("\n");
    out.println(" ");
    lineOfText.clear();
    out.close();
    catch (FileNotFoundException e) {
    System.out.println("file not found!");
    catch (IOException e) {
    System.out.println(e);
    Thanks

    Well, I thought I had this program finished, then I realized I need to match the keyword anywhere in the file(including within a word) and print out each line that "contains" the keyword in each file. So, I need some way of testing to see if the keyword is a part of each word and then flag the line that contains the keyword. Is there some method to do this? Thanks
    Here's the code I have now:
    import java.util.Scanner;
    import java.io.IOException;
    import java.io.FileNotFoundException;
    import java.io.FileInputStream;
    import java.io.PrintWriter;
    public class Find {
        static String line = "";
        static boolean flag = false;
        static boolean flag2 = false;
        public static void main(String args[]) {
                    run(args);
        public static void run(String args[]) {
            try {
                PrintWriter out = new PrintWriter("output.txt");
                String keyword = args[0];
                System.out.print("Searching for the keyword: " + keyword);
                out.print("Searching for the keyword: " + keyword);
                System.out.print("  in files: ");
                out.print("  in files: ");
                for (int k = 1; k < args.length; k++)
                     System.out.print(args[k] + " ");
                     out.print(args[k] + " ");
                     System.out.println("\n");
                     out.println("");
                     out.println("");
                for (int i = 1; i < args.length; i++) {
                    Scanner in = new Scanner(new FileInputStream(args));
    while (in.hasNextLine()) {
    line = in.nextLine();
    String[] splitLine = line.split(" ");
    for (int j=0; j < splitLine.length; j++) {
    if (splitLine[j].equals(keyword) && flag2 == false) {
    flag = true;
    flag2 = true;
    System.out.print(args[i] + ": " + line + "\n");
    out.println(args[i] + ": " + line);
    flag2 = false;
    System.out.print("\n");
    out.println(" ");
    out.close();
    catch (FileNotFoundException e) {
    System.out.println("file not found!");
    catch (IOException e) {
    System.out.println(e);

  • How to get Text from (.txt) file to display in the JTextArea ?

    How to get Text from (.txt) file to display in the JTextArea ?
    is there any code please tell me i am begginer and trying to get data from a text file to display in the JTextArea /... please help...

    public static void readText() {
      try {
        File testFile = new File(WorkingDirectory + "ctrlFile.txt");
        if (testFile.exists()){
          BufferedReader br = new BufferedReader(new FileReader("ctrlFile.txt"));
          String s = br.readLine();
          while (s != null)  {
            System.out.println(s);
            s = br.readLine();
          br.close();
      catch (IOException ex){ex.printStackTrace();}
    }rykk

Maybe you are looking for