How to load a text file int JEditorPane and highlight some words (Urgent !)

I want to load a text file into a JEditorPane and then highlights some keywords such as while,if and else.I am using an EditorKit in order to style the JEditorPane. I have no difficulty while giving the input through the keyboard but lots of exceptions are thrown if i try to load the string from a file.

Hi,
I think the setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace) will solve the problem.
You can create your own Styled Document and set it to the Editor Pane.

Similar Messages

  • "how to load a text file to oracle table"

    hi to all
    can anybody help me "how to load a text file to oracle table", this is first time i am doing, plz give me steps.
    Regards
    MKhaleel

    Usage: SQLLOAD keyword=value [,keyword=value,...]
    Valid Keywords:
    userid -- ORACLE username/password
    control -- Control file name
    log -- Log file name
    bad -- Bad file name
    data -- Data file name
    discard -- Discard file name
    discardmax -- Number of discards to allow (Default all)
    skip -- Number of logical records to skip (Default 0)
    load -- Number of logical records to load (Default all)
    errors -- Number of errors to allow (Default 50)
    rows -- Number of rows in conventional path bind array or between direct path data saves (Default: Conventional path 64, Direct path all)
    bindsize -- Size of conventional path bind array in bytes (Default 256000)
    silent -- Suppress messages during run (header, feedback, errors, discards, partitions)
    direct -- use direct path (Default FALSE)
    parfile -- parameter file: name of file that contains parameter specifications
    parallel -- do parallel load (Default FALSE)
    file -- File to allocate extents from
    skip_unusable_indexes -- disallow/allow unusable indexes or index partitions (Default FALSE)
    skip_index_maintenance -- do not maintain indexes, mark affected indexes as unusable (Default FALSE)
    commit_discontinued -- commit loaded rows when load is discontinued (Default FALSE)
    readsize -- Size of Read buffer (Default 1048576)
    external_table -- use external table for load; NOT_USED, GENERATE_ONLY, EXECUTE
    (Default NOT_USED)
    columnarrayrows -- Number of rows for direct path column array (Default 5000)
    streamsize -- Size of direct path stream buffer in bytes (Default 256000)
    multithreading -- use multithreading in direct path
    resumable -- enable or disable resumable for current session (Default FALSE)
    resumable_name -- text string to help identify resumable statement
    resumable_timeout -- wait time (in seconds) for RESUMABLE (Default 7200)
    PLEASE NOTE: Command-line parameters may be specified either by position or by keywords. An example of the former case is 'sqlldr scott/tiger foo'; an example of the latter is 'sqlldr control=foo userid=scott/tiger'. One may specify parameters by position before but not after parameters specified by keywords. For example, 'sqlldr scott/tiger control=foo logfile=log' is allowed, but 'sqlldr scott/tiger control=foo log' is not, even though the position of the parameter 'log' is correct.
    SQLLDR USERID=GROWSTAR/[email protected] CONTROL=D:\PFS2004.CTL LOG=D:\PFS2004.LOG BAD=D:\PFS2004.BAD DATA=D:\PFS2004.CSV
    SQLLDR USERID=GROWSTAR/[email protected] CONTROL=D:\CLAB2004.CTL LOG=D:\CLAB2004.LOG BAD=D:\CLAB2004.BAD DATA=D:\CLAB2004.CSV
    SQLLDR USERID=GROWSTAR/[email protected] CONTROL=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.CTL LOG=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.LOG BAD=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.BAD DATA=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.CSV

  • How to load a text file?

    I'm trying to load a text file and I've run into a wall. So
    far, I've loaded swf files, image files and XML files without
    problems. But the text files just don't seem to load.
    It's not a tough situation. The files are in the same
    directory as the application. When I run it, I see no sign that the
    file has loaded, but haven't found the error trapping to tell me
    what is (not) going on.
    The code below was culled from examples on the web, they seem
    fairly consistent, and they are copied pretty much exactly. and I
    put them both into a single action to test them.
    Any clues as to what is not happening? I need to read an old
    txt data file that was used with AS2, with pairs of names and
    variables. The first example just reads a couple of variables. The
    second just reads some random text. I'm just trying to see what
    works here, so I can incorporate working code into the real
    program.
    Thanks for your help.

    Thanks Joergen,
    I put in the changes you suggested and still no sign that the
    files are even being opened., but it's very good to have the
    feedback. Just the fact that someone is getting them to run gives
    me confidence in the basic code. I'll hack on it more and let you
    know what the answer turns out to be for me.
    Thanks.

  • How to load external text file into a Form?

    Hi,
    I made a menu with 1-5 in a Form and 5 external text files. I want the user who is able to view the text content of the text file when he chooses one of them from the menu. And the text file screen has a "Back" command button to let him go back.
    How can I do it and can it support other languages such as Chinese and Japanese?
    Thanks for help.
    gogo

    Sorry, I made the mistake about the subject, it should be loading local file, not external file through http.
    I wrote a method but it throwed an exception when the midlet was run.
    private void loadText()
    try {
    InputStream is = this.getClass().getResourceAsStream("/text.txt");
    StringBuffer sb = new StringBuffer();
    int chr;
    while ((chr = is.read()) != -1)
    sb.append((char) chr);
    is.close();
    catch (Exception e)
    System.out.println("Error occurs while reading file");
    I put the text.txt file in the same folder with the main file (extends midlet). How can I load the text content and display it on StringItem?
    Thanks for any help.
    gogo

  • How to load a text file (ASCII) into a TS string variable?

    I need to load a ASCII file into a TS string variable for subsequent processing. I tried the SecuenceBuilder DLL (in the examples directory) but it seems that this DLL has a bug. Some text files are not loaded properly. I have also tried the kernel32 functions (openfile, createfile, readfile ... ) handling them as a C program, but with no success. The property loader feature of TS is not the suitable solution for me, because I would have to modify all my text files to include some specific fields (step name, variables, starmarker ...). Doy you know an alternative procedure to load text files or any DLL that implements what I look for ? Any help would be grateful. Cesar ([email protected])

    Hi Cesar,
    I don't know if you have found a solution, but attached is a DLL built in VC that will read the text out of a file into a TestStand variable. The attached sequence file \SequenceFile1.seq contains a step type that is set to call the DLL responsible for reading the file. It reads the file specified under Step.FilePath and stores the data in Step.ReadData. Please let me know if this works for you. I have attached the source as well.
    Regards,
    Bob
    Attachments:
    ReadFile.zip ‏3628 KB

  • How to load a text file in a Java swings application

    hi,
    I am trying to retrieve a Java code(or say any text from an existing file) and display it in a swing application.
    I am not able to do so.
    Please help me.

    public String readFile(File f){
              try {
                   BufferedReader read = new BufferedReader(new FileReader(f));
                   String line = read.readLine();
                   String total = "";
                   while(line != null){
              //          System.out.println(line);
                        total += line;
                        line = read.readLine();
                   read.close();
                   return total;
              } catch (Exception e){
                   e.printStackTrace();
              return "";
         }that will read a file into a string, i hope you can figure out the rest

  • How to Create a batch file to display and count specific words in log file

    Hi All,
    I have requirement Program to be written that will go through a log file and look for following key words.
    Unexpected Essbase error
    And also it will count the # of times the word error appear in a log file.
    You may use batch file or Perl script to complete this task.
    e.g. in the log file - It will flag yes that keyword "Unexpected Essbase error" found and word error occurs 9 times.
    Pls help me in know process to achieve above requirement.
    and pls let me know what is perl scripting ?
    Thanks in Advance
    Regards,
    SM

    Sorry but it sounds like you have been asked to do something and you have pasted the requirement on the forum, have you done any research to find out which scripting language you are going to use or any find examples, there are so many differents examples and help on the internet it just takes a little bit of time and investment.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Reading text file to JEditorPane

    Hi,
    I'm trying to read text file to JEditorPane and it works but first line is always missing. Here is the code for reading:
    try {
       in = new BufferedReader(new FileReader(filePathIn));
       while ((lineIn = in.readLine()) != null) {
            editorPane.read(in, new Object());
    } catch (IOException ie)...Any suggestions?

    in.readLine is changing the input stream position.
    Do this instead:
    FileInputStream in = new FileInputStream(filePathIn);
    while (in.available() != 0)
        editorPane.read(in, new Object());

  • How to read a text file using Java

    Guys,
    Good day!
    Please help me how to read a text file using Java and create/convert that text file into XML.
    Thanks and God Bless.
    Regards,
    I-Talk

         public void fileRead(){
                 File aFile =new File("myFile.txt");
             BufferedReader input = null;
             try {
               input = new BufferedReader( new FileReader(aFile) );
               String line = null;
               while (( line = input.readLine()) != null){
             catch (FileNotFoundException ex) {
               ex.printStackTrace();
             catch (IOException ex){
               ex.printStackTrace();
         }This code is to read a text file. But there is no such thing that will convert your text file to xml file. You have to have a defined XML format. Then you can read your data from text files and insert them inside your xml text. Or you may like to read xml tags from text files and insert your own data. The file format of .txt and .xml is far too different.
    cheers
    Mohammed Jubaer Arif.

  • How to load a .cap file

    i am new to smartcard programming...
    now i am able to compile sample card program and and generated .cap file.
    now my question is how to load that .cap file onto simulator and also smartcard.
    my requirement is to store some value on smart card and retrive that value and update it. what is the process to achive this.plz mail me in detail to my id : [email protected] or [email protected]
    advance thanks for mailing to me ....

    i am new to smartcard programming...
    now i am able to compile sample card program and and generated .cap file.
    now my question is how to load that .cap file onto simulator and also smartcard.
    my requirement is to store some value on smart card and retrive that value and update it. what is the process to achive this.plz mail me in detail to my id : [email protected] or [email protected]
    advance thanks for mailing to me ....

  • How can I use sql loader to load a text file into a table

    Hi, I need to load a text file that has records on lines tab delimited into a table. How would I be able to use the sql loader to do this? I am using korn shell to do this. I am very new at this...so any kind of helpful examples or documentation would be very appreciated. I would love to see some examples to help me understand if possible. I need help! Thanks alot!

    You should check out the documentation on SQL*Loader in the online Oracle document titled Utilities. Here's a link to the 9iR2 version of it: http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/server.920/a96652/part2.htm#436160
    Hope this helps.

  • How to load Cell Text (~8000 bytes) in HFM from a Flat File using FDMEE?

    Hi,
    There are numerous posts on OTN describing how to load cell text using the Create Memo API. However, we are struggling to know how do we use FDMEE to load Cell text which is about 8000 bytes from a flat file?
    Basically HFM gives us the flexibility to enter a Free-Form Cell Text with default size of 8000 bytes (which may be increased). However, when we try to manupilate FDMEE and load this to HFM, there is no place-holder/column in FDMEE Staging tables that has sufficient size to place such a long text. All the ATTR are not more than 20 bytes and UDx columns are only 75 bytes.
    Has anyone faced a similar issue and built a workaround for this problem?
    Thanks!

    Did you consider External Tables ?

  • Loading a text file in a gzip or zip archive using an applet to a String

    How do I load a text file in a gzip or zip archive using an applet to a String, not a byte array? Give me both gzip and zip examples.

    This doesn't work:
              try
                   java.net.URL url = new java.net.URL(getCodeBase() + filename);
                   inputStream = new java.io.BufferedInputStream(url.openStream());
                   if (filename.toLowerCase().endsWith(".txt.gz"))
                        inputStream = (java.io.InputStream)(new java.util.zip.GZIPInputStream(inputStream));
                   else if (filename.toLowerCase().endsWith(".zip"))
                        java.util.zip.ZipInputStream zipInputStream = new java.util.zip.ZipInputStream(inputStream);
                        java.util.zip.ZipEntry zipEntry = zipInputStream.getNextEntry();
                        while (zipEntry != null && (zipEntry.isDirectory() || !zipEntry.getName().toLowerCase().endsWith(".txt")))
                             zipEntry = zipInputStream.getNextEntry();
                        if (zipEntry == null)
                             zipInputStream.close();
                             inputStream.close();
                             return "";
                        inputStream = zipInputStream;
                   else
                   byte bytes[] = new byte[10000000];
                   byte s;
                   int i = 0;
                   while (((s = inputStream.read())) != null)
                        bytes[i++] = s;
                   inputStream.close();
            catch (Exception e)
              }

  • How to convert a text file in lower case to upper case?

    I've a beginner in java world and I just come through the tutorial in http://java.sun.com/docs/books/tutorial/essential/io/filestreams.html showing how to copy a text file:
    import java.io.*;
    public class Copy {
    public static void main(String[] args) throws IOException {
         File inputFile = new File("farrago.txt");
         File outputFile = new File("outagain.txt");
    FileReader in = new FileReader(inputFile);
    FileWriter out = new FileWriter(outputFile);
    int c;
    while ((c = in.read()) != -1)
    out.write(c);
    in.close();
    out.close();
    And I would like to ask how to covert all lower case letters in input file to upper case letter in output file at the same time of copying.
    I guess it'll be using Character.toUpperCase(c), but I don't know how to do it actually.
    Any help would be much appreciated.

    Hope this helps
    import java.io.*;
    public class Copy {
    public static void main(String[] args) throws IOException {
    File inputFile = new File("farrago.txt");
    File outputFile = new File("outagain.txt");
    FileReader in = new FileReader(inputFile);
    FileWriter out = new FileWriter(outputFile);
    BufferedReader buff = new BufferedReader(in);
    String c;
    while ((c = buff.readLine()) != null)
    out.write(c.toUpperCase());
    in.close();
    out.close();
    }

  • How to read several text files at a time

    Dear all
          Read and write one text file is not a problem, but  what confusies me is how to read several text files at one time, in the meanwhile,
    is it possible to display the name of the text file?
    For example, assuming I want to load file" cha 1, cha 2 , cha 3, " at one time and show their names, how to hadle with it
    I have reviewed some files and it is not helpful

    Either with a 'for' loop like in the lib you have attached, or like this attached VI
    that's it
    Message Edited by devchander on 05-30-2006 05:11 AM
    Attachments:
    MULTIPLE READ.vi ‏44 KB

Maybe you are looking for