Adding data from a text file into a JTextArea

I'm working on a blogging program and I need to add data from a text file named messages.txt into a JTextArea named messages. How do I go about doing this?

then you need to be more specific in what you need help with because those are two commonly used options for reading data in from a file. what have you tried? where is your code failing? what kind of errors are you getting? of course it looks like others in the forum have already reprimanded you for failing to post properly.
i have used both FileReader and the nio package for cfg and ini files which are both just txt files as well as massive data files. so tell me how they dont help you?

Similar Messages

  • How do you read data from a text file into a JTextArea?

    I'm working on a blogging program and I need to add data from a text file named messages.txt into a JTextArea named messages. How do I go about doing this?

    Student_Coder wrote:
    1) Read the file messages.txt into a String
    2) Initialize messages with the String as the textSwing text components are designed to use Unix-style linefeeds (\n) as line separators. If the text file happens to use a different style, like DOS's carriage-return+linefeed (\r\n), it needs to be converted. The read() method does that, and it saves the info about the line separator style in the Document so the write() method can re-convert it.
    lethalwire wrote:
    They have 2 different ways of importing documents in this link:
    http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html
    Neither of those methods applies to JTextAreas.

  • How to do import data from the text file into the mathscript window?

    Could anyone tell me how to do import data from text file into mathscript window for labview 8?
    MathScript Window openned, File, Load Data - it has options: custom pattern (*.mlv) or all files. 
    Thanks

    Hi Milan,
    Prior to loading data in Mathscript Window , you have to save the data from the Mathscript window (the default extension of the file is .mlv but you can choose any extension). This means that you cannot load data from a text file  that was not created using the Mathscript window.
    Please let me know if you have any further questions regarding this issue.
    Regards,
    Ankita

  • How to import data from a text file into a table

    Hello,
    I need help with importing data from a .csv file with comma delimiter into a table.
    I've been struggling to figure out how to use the "Import from Files" wizard in Oracle 10g web-base Enterprise Manager.
    I have not been able to find a simple instruction on how to use the Wizard.
    I have looked at the Oracle Database Utilities - Overview of Oracle Data Pump and the Help on the "Import: Files" page.
    Neither one gave me enough instruction to be able to do the import successfully.
    Using the "Import from file" wizard, I created a Directory Object using the Create Directory Object button. I Copied the file from which i needed to import the data into the Operating System Directory i had defined in the Create Directory Object page. I chose "Entire files" for the Import type.
    Step 1 of 4 is the "Import:Re-Mapping" page, I have no idea what i need to do on this page. All i know i am not tying to import data that was in one schema into a different schema and I am not importing data that was in one tablespace into a different tablespace and i am not R-Mapping datafiles either. I am importing data from a csv file.
    For step 2 of 4, "Import:Options" page, I selected the same directory object i had created.
    For step 3 of 4, I entered a job name and a description and selected Start Immediately option.
    What i noticed going through the wizard, the wizard never asked into which table do i want to import the data.
    I submitted the job and I got ORA-31619 invalid dump file error.
    I was sure that the wizard was going to fail when it never asked me into which table do i want to import the data.
    I tried to use the "imp" utility in command-line window.
    After I entered (imp), i was prompted for the username and the password and then the buffer size as soon as i entered the min buffer size I got the following error and the import was terminated:
    C:\>imp
    Import: Release 10.1.0.2.0 - Production on Fri Jul 9 12:56:11 2004
    Copyright (c) 1982, 2004, Oracle. All rights reserved.
    Username: user1
    Password:
    Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Produc
    tion
    With the Partitioning, OLAP and Data Mining options
    Import file: EXPDAT.DMP > c:\securParms\securParms.csv
    Enter insert buffer size (minimum is 8192) 30720> 8192
    IMP-00037: Character set marker unknown
    IMP-00000: Import terminated unsuccessfully
    Please show me the easiest way to import a text file into a table. How complex could it be to do a simple import into a table using a text file?
    We are testing our application against both an Oracle database and a MSSQLServer 2000 database.
    I was able to import the data into a table in MSSQLServer database and I can say that anybody with no experience could easily do an export/import in MSSQLServer 2000.
    I appreciate if someone could show me how to the import from a file into a table!
    Thanks,
    Mitra

    >
    I can say that anybody with
    no experience could easily do an export/import in
    MSSQLServer 2000.
    Anybody with no experience should not mess up my Oracle Databases !

  • Reading data from a text file into PAS - Dimension member names truncated

    Hi,
    I created a procedure to dump variables and data into a text file to load into another model. I used a semicolon as a field seperator.
    The data, measures and dimension members are dumped properly into a text file and no dimension member names are truncated .
    However when I read the data into  a measure, and I issue a peek command, dimension meber names are read in truncated
    and remain full names in the text file. Any reason for this? What do I need to do to prevent this from happening?
    THanks.
    Lungile

    Hi Lungile,
    The problem that you're likely having is that you haven't created a file description for the file from which you're reading.  When loading data into Application Server from a text file, you would normally go through three steps:
    1. Enter the ACCESS EXTERNAL subsystem
    2. Specify the name of the file to be read
    3. Specify the format of the file field names, types, widths, and positions.
    If you go into the Application Server help, select "Application Server Help", then "Application Server at the command level", then "Variables and reading in data", and then "Reading an external file", you will have the process of the steps you need to follow outlined for you, including links to the help topic for each command you need to issue.
    So what I think you need to do is use the DESCRIPTION command to specify the names of your fields, their type, and also their width, in order to ensure no truncation of data on the load.
    The same DESCRIPTION statement is required if you want to use your text file as the source of a dimension.
    Hope this helps,
    Robert

  • Importing data from a text file into a table

    Hi Experts,
    I have the following flat file
    weekly_eft_repo  1.0                                                                                                       Page: 1
    CDC:00304 / Sat Oct-31-2009     Weekly EFT Sweep for 25/10/09 - 31/10/09  Effective Date 03/11/09         Sat Oct-31-2009 22:06:14
    Bill to
    Retailer Retailer Name                  Name on Bank Account           Bank ABA   Bank Acct            On-line Amount  Instant Amount  Total Amount
    ======== ============================== ============================== ========== ==================== =============== =============== ===============
    0200101 Triolet Popular Store          Triolet Popular Store          111111111  62030100130659            10,868.00            0.00       10,868.00
    0200103 Le Cacharel Snack              Le Cacharel Snack              111111111  62030100130813             9,728.00            0.00        9,728.00
    0200104 Advanced Co-operative Self Ser Advanced Co-operative Self Ser 111111111  111111111                  7,334.00            0.00        7,334.00
    0200105 Chez Popo Supermarket          Chez Popo Supermarket          111111111  61030100044898            30,932.00            0.00       30,932.00
    0200106 Vana Supermarket               Vana Supermarket               111111111  111111111                 17,775.00            0.00       17,775.00
    0200107 Mont Choisy Store              Mont Choisy Store              111111111  62030100130804             8,840.00            0.00        8,840.00
    0200108 Vijay Store                    Vijay Store                    111111111  62030100131229            16,416.00            0.00       16,416.00
    0200109 Neptune Confection             Neptune Confection             111111111  62030100130931            11,077.00            0.00       11,077.00
    0200110 Antoine Store                  Antoine Store                  111111111  111111111                  2,470.00            0.00        2,470.00
    0200111 P.S.C Cold Storage             P.S.C Cold Storage             111111111  111111111                 10,431.00            0.00       10,431.00
    0200113 Mini Prix Boutique             Mini Prix Boutique             111111111  62030100131501            26,315.00            0.00       26,315.00
    0200114 Hotel Cassim                   Hotel Cassim                   111111111  111111111                135,147.00            0.00      135,147.00
    0200116 Aman Snack                     Aman Snack                     111111111  62030100129481             7,334.00            0.00        7,334.00
    0200117 Best For Less Company Ltd      Best For Less Company Ltd      111111111  111111111                  3,325.00            0.00        3,325.00
    0200118 Central Way                    Central Way                    111111111  111111111                 25,137.00            0.00       25,137.00I need to insert the data it contains into the following table
    TABLE weekly_eft_report_temp
    Name                                      Null?    Type                       
    BILL_TO_RETAILER                          NOT NULL VARCHAR2(15)               
    RETAILER_NAME                                      VARCHAR2(100)              
    NAME_ON_BANK_ACCOUNT                               VARCHAR2(100)              
    BANK_ABA                                           VARCHAR2(1)                
    BANK_ACCT                                          VARCHAR2(1)                
    ON_LINE_AMOUNT                                     NUMBER                     
    INSTANT_AMOUNT                                     NUMBER                     
    TOTAL_AMOUNT                                       NUMBER Whats the easiest and best way to proceed on that?
    Thanks
    Kevin

    I am with Chris on this one.
    If those headers are repeating in your text file, you could run a simple script to cleanse the data first and make the file fit for SQL*Loader.
    Here's an example with Perl, I hope the header of Page 2 and onwards resembles what you have in your file. I've snipped some data from the far right so that it fits on my terminal screen:
    $
    $ # show the contents of the data file
    $
    $ cat report.dat
    weekly_eft_repo  1.0                                                                                        Page: 1
    CDC:00304 / Sat Oct-31-2009 Weekly EFT Sweep for 25/10/09 - 31/10/09  Effective Date 03/11/09 Sat Oct-31-2009 22:06:14
    Bill to
    Retailer Retailer Name                  Name on Bank Account           Bank ABA   Bank Acct            On-line Amount
    ======== ============================== ============================== ========== ==================== ===============
    0200101 Triolet Popular Store          Triolet Popular Store          111111111  62030100130659            10,868.00
    0200103 Le Cacharel Snack              Le Cacharel Snack              111111111  62030100130813             9,728.00
    0200104 Advanced Co-operative Self Ser Advanced Co-operative Self Ser 111111111  111111111                  7,334.00
    0200105 Chez Popo Supermarket          Chez Popo Supermarket          111111111  61030100044898            30,932.00
    0200106 Vana Supermarket               Vana Supermarket               111111111  111111111                 17,775.00
    weekly_eft_repo  1.0                                                                                        Page: 2
    CDC:00304 / Sat Oct-31-2009 Weekly EFT Sweep for 25/10/09 - 31/10/09  Effective Date 03/11/09 Sat Oct-31-2009 22:06:14
    Bill to
    Retailer Retailer Name                  Name on Bank Account           Bank ABA   Bank Acct            On-line Amount
    ======== ============================== ============================== ========== ==================== ===============
    0200107 Mont Choisy Store              Mont Choisy Store              111111111  62030100130804             8,840.00
    0200108 Vijay Store                    Vijay Store                    111111111  62030100131229            16,416.00
    0200109 Neptune Confection             Neptune Confection             111111111  62030100130931            11,077.00
    0200110 Antoine Store                  Antoine Store                  111111111  111111111                  2,470.00
    0200111 P.S.C Cold Storage             P.S.C Cold Storage             111111111  111111111                 10,431.00
    weekly_eft_repo  1.0                                                                                        Page: 3
    CDC:00304 / Sat Oct-31-2009 Weekly EFT Sweep for 25/10/09 - 31/10/09  Effective Date 03/11/09 Sat Oct-31-2009 22:06:14
    Bill to
    Retailer Retailer Name                  Name on Bank Account           Bank ABA   Bank Acct            On-line Amount
    ======== ============================== ============================== ========== ==================== ===============
    0200113 Mini Prix Boutique             Mini Prix Boutique             111111111  62030100131501            26,315.00
    0200114 Hotel Cassim                   Hotel Cassim                   111111111  111111111                135,147.00
    0200116 Aman Snack                     Aman Snack                     111111111  62030100129481             7,334.00
    0200117 Best For Less Company Ltd      Best For Less Company Ltd      111111111  111111111                  3,325.00
    0200118 Central Way                    Central Way                    111111111  111111111                 25,137.00
    $
    $
    $ # snip off the headers using Perl so that the transformed file has just the data to load
    $
    $ perl -lne 'BEGIN{$/=""} s/^weekly.*?=\n//msg; print' report.dat
    0200101 Triolet Popular Store          Triolet Popular Store          111111111  62030100130659            10,868.00
    0200103 Le Cacharel Snack              Le Cacharel Snack              111111111  62030100130813             9,728.00
    0200104 Advanced Co-operative Self Ser Advanced Co-operative Self Ser 111111111  111111111                  7,334.00
    0200105 Chez Popo Supermarket          Chez Popo Supermarket          111111111  61030100044898            30,932.00
    0200106 Vana Supermarket               Vana Supermarket               111111111  111111111                 17,775.00
    0200107 Mont Choisy Store              Mont Choisy Store              111111111  62030100130804             8,840.00
    0200108 Vijay Store                    Vijay Store                    111111111  62030100131229            16,416.00
    0200109 Neptune Confection             Neptune Confection             111111111  62030100130931            11,077.00
    0200110 Antoine Store                  Antoine Store                  111111111  111111111                  2,470.00
    0200111 P.S.C Cold Storage             P.S.C Cold Storage             111111111  111111111                 10,431.00
    0200113 Mini Prix Boutique             Mini Prix Boutique             111111111  62030100131501            26,315.00
    0200114 Hotel Cassim                   Hotel Cassim                   111111111  111111111                135,147.00
    0200116 Aman Snack                     Aman Snack                     111111111  62030100129481             7,334.00
    0200117 Best For Less Company Ltd      Best For Less Company Ltd      111111111  111111111                  3,325.00
    0200118 Central Way                    Central Way                    111111111  111111111                 25,137.00
    $
    $ You could do an inline substitution with Perl, or redirect it to a temp file and then move back to the original file. In either case, you have just the relevant data for the next step.
    Again, Perl is just one option. On Unix/Linux systems, you have a large number of utilities/scripting languages that can perform almost any kind of data transformation.
    HTH,
    isotope

  • Reading data from a text file into a JTextField

    So I am writing a program that will write to and read from a large database. I was hoping to allow a graphical interface for the reading of the data, but I keep getting an error;
    Incompatible Types
    Found: java.lang.string
    Required: javax.swing.JTextField
    Now I know that this means the are incompatible (like trying to give an integer variable a string command) but I can't find any documentation on how to change the String into a JTextField format. I've found several references on how to do the reverse, but with my lack of JAVA knowledge I can't seem to get it to work. (Tried things like getText() and the like, but just end up with more errors).
    *On a side note, is there an easier way to go about reading a file line by line, with each line going into a seperate JTextField, than;
    BufferedReader r;
    try {
    r = new BufferedReader(new FileReader("C:\\temp\\test.txt"));
    while ((thisLine = r.readLine()) != null) {
    array[i] = thisLine;
    i = i + 1
    and then assigning each JTextField it's own array slot?*
    Thank you for your help.

    Try something like this for putting the text in a control:
    import java.awt.Dimension;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    public class Junk{
      String[] s = {"This is String 1.", "This is String 2.", "This is String 3."};
      Junk(){
      public void makeIt(){
        JFrame j = new JFrame("Forum Junk");
        j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel p = new JPanel();
        p.setPreferredSize(new Dimension(300, 200));
        JTextArea jt = new JTextArea();
        p.add(jt);
        j.add(p);
        jt.setText(s[0]);
        jt.append("\n\r"+s[1]);
        jt.append("\n\r"+s[2]);
        j.pack();
        j.setVisible(true);
      public static void main(String[] args) {
        Junk j = new Junk();
        j.makeIt();
    }Depending on your design you may be able to do away with your array and append the text directly to the JTextArray after each line is read.

  • Error while loading data from a text file to a datastore

    Hi all,
    i am a starter in ODI. I am trying to load data from a text file into a datastore. I have put the file on a unix server whose location is defined in the topology manager. when i am trying to "view data" it is giving me error file does not exist at <location where i have put the file>. Please help me

    Hi,
    1. If your files are on a remote File System, you will need to copy one of your files to the machine ODI Designer is running on to allow ODI to retrieve the metadata information of the file.
    2. In Topology create a Physical Schema, the directory you enter for Data and Work Schema should point at this local file.
    3. Then define the File Datastore in ODI Designer. Enter a name, browse and select the file and fill in each filed of the Files tab.
    * If its a Fixed file, click on the grid icon on the Columns tab to enter the columns and have Automatic Adjustment checked.
    * If its a Delimited file, use the Reverse button on the Columns tab to reverse the columns.
    * Right click on the File Datastore select View Data, if you can view data, that means the File Datastore has been defined correctly.
    * If not, check each tab of the File Datastore to make sure everything is defined correctly and retry.
    4. Once View Data is successful, you now change the directories (Data and Work Schema in Topology) to point at the remote File System. These directories must be accessible to the ODI Agent that will be used to run the transformations. The directory can be an absolute path (m:/public/data/files) or relative to the ODI Agent startup directory (../demo/files). It is strongly advised to use a UNC (independent from the execution location) for the path. When running the transformations with "no agent", the directory is relative to the directory where Oracle Data Integrator has been installed.
    You need to have a agent process running at the system where your source file resides .
    Then while running the odi interface choose that agent .
    Thanks,
    Sutirtha

  • SQL Loader-How to insert -ve & date values from flat text file into coloumn

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide.

    Question: How to insert -ve & date values from flat text file into coloumns in a table.
    Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
    How to load such values in columns of database using SQL Loader?
    Please guide. Try something like
    someDate    DATE 'DDMMYYYY'
    someNumber1      "TO_NUMBER ('s99999999.00')"
    someNumber2      "TO_NUMBER ('99999999.00s')"Good luck,
    Eric Kamradt

  • How to read a tab seperated data from a text file using utl_file

    Hi,
    How to read a tab seperated data from a text file using utl_file...
    I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....
    Thanks in advance...
    Naveen

    Naveen Nishad wrote:
    How to read a tab seperated data from a text file using utl_file...
    I know if we use UTL_FILE.get_line we can read the whole line...but i need to read the tab separated value separately.....If it's a text file then UTL_FILE will only allow you to read it a line at a time. It is then up to you to split that string up (search for split string on this forum for methods) into it's individual components.
    If the text file contains a standard structure on each line, i.e. it is a fixed delimited structure, then you could use external tables to read the data instead.

  • How to get data of tabulated text file into internal table

    hi all,
    i want to get data from tabulated text file(notepad) into internal table. i searched in SCN and got lot of post regarding  how to convert excel file into internal table but i didnt get posts regarding text file.
    thanks
    SAchin

    try:
    DATA: BEGIN OF tabulator,
            x(1) TYPE x VALUE '09',
          END OF tabulator.
      READ DATASET file INTO wa.
    split wa at tabulator into table itab.
    A.

  • Hi i am new to labview. i want to extract data from a text file and display it on the front panel. how do i proceed??

    Hi i am new to labview
    I want to extract data from a text file and display it on the front panel.
    How do i proceed??
    I have attached a file for your brief idea...
    Attachments:
    extract.jpg ‏3797 KB

    RoopeshV wrote:
    Hi,
    The below code shows how to read from txt file and display in the perticular fields.
    Why have you used waveform?
    Regards,
    Roopesh
    There are so many things wrong with this VI, I'm not even sure where to start.
    Hard-coding paths that point to your user folder on the block diagram. What if somebody else tries to run it? They'll get an error. What if somebody tries to run this on Windows 7? They'll get an error. What if somebody tries to run this on a Mac or Linux? They'll get an error.
    Not using Read From Spreadsheet File.
    Use of local variables to populate an array.
    Cannot insert values into an empty array.
    What if there's a line missing from the text file? Now your data will not line up. Your case structure does handle this.
    Also, how does this answer the poster's question?

  • How to load Test data from a Text file in ECATT

    Hi,
    I have created a test configuration with a test script, system data container, and test data container.
    I have done the recording of a transaction and created the script. Parameterization is done for the script and have imported those parameters from script in to the data container.
    I am trying to load a the data from a text file on the local work-station. The data is not being read.
    Please explain this in detail (step by step) as I am very new to ECATT.
    I am trying this on SAP ECC 6.0 IDES server.
    Thanks in Advance
    Vikas Patil

    Please explain this in detail (step by step) as I am very new to ECATT.
    Thanks in Advance
    Vikas Patil

  • How can I plott data from a text file in the same way as a media player using the pointer slide to go back and fort in my file?

    I would like to plott data from a text file in the same way as a media player does from a video file. I’m not sure how to create the pointer slide function. The vi could look something like the attached jpg.
    Please, can some one help me?
    Martin
    Attachments:
    Plotting from a text file like a media player example.jpg ‏61 KB

    HI Martin,
    i am not realy sure what you want!?!?
    i think you want to display only a part of the values you read from XYZ
    so what you can do:
    write all the values in an array.
    the size of the array is the max. value of the slide bar
    now you can select a part of the array (e.g. values from 100 to 200) and display this with a graph
    the other option is to use the history function of the graphes
    regards
    timo

  • Reading one line from a text file into an array

    i want to read one line from a text file into an array, and then the next line into a different array. both arays are type string...i have this:
    public static void readAndProcessData(FileInputStream stream){
         InputStreamReader iStrReader = new InputStreamReader (stream);
         BufferedReader reader = new BufferedReader (iStrReader);
         String line = "";          
         try{
         int i = 0;
              while (line != null){                 
                   names[i] = reader.readLine();
                   score[i] = reader.readLine();
                   line = reader.readLine();
                   i++;                
              }catch (IOException e){
              System.out.println("Error in file access");
    this section calls it:
    try{                         
         FileInputStream stream = new FileInputStream("ISU.txt");
              HighScore.readAndProcessData(stream);
              stream.close();
              names = HighScore.getNames();
              scores = HighScore.getScores();
         }catch(IOException e){
              System.out.println("Error in accessing file." + e.toString());
    it gives me an array index out of bounds error

    oh wait I see it when I looked at the original quote.
    They array you made called names or the other one is prob too small for the amount of names that you have in the file. Hence as I increases it eventually goes out of bounds of the array so you should probably resize the array if that happens.

Maybe you are looking for

  • Help Restoring and Backing Up

    I want to restore my iPhone 3GS but when i do it pauses right in the middle of when it's loading. no error shows up cause it doesnt finish loading. Another thing is when my phone backs up it never finishes my phone always freezes while its backing up

  • Itunes/ipod freeze when i try to sync my ipod

    yesterday i downloaded the most recent version of itunes. i successfully synced my ipod the first time. but now when i try to sync my ipod, itunes freezes up and eventually quits sync-ing. i've restored my ipod twice, but it hasn't helped -- each tim

  • Trouble drawing on saved images in whiteboard, please help!

    I use the Image.IO.write(image,"png",file) method to save my whiteboard drawings onto a file and it displays fine when I import it. But when I draw on it it seems some of my whiteboard buttons are "blending in" with the drawing area where the image i

  • Nokia 6131 to be switched off for data transfer

    I have a strange problem. I have 2 Nokia 6131 (NFC enabled) phones in my hand .In the first phone I have an application(Midlet) which writes data to the internal mifare of the same phone. Now I brings the second phone closer to first one.I want secon

  • Order of execution of JPDK Portlets inside the same Portal Page

    We have 2 Sample JPDK Portlets from the same provider on our page - A LoginPortlet that accepts the username and Password - A Welcome Bin Portlet that shows the logged in user's details Once the user enters username and password in the LoginPortlet,