Problem reading txt file

Hi
I have a shell cluster where I type different data for my file. Then I save this to txt file. The problem is when I want to open the file and use the data for the same shell cluster, which is now an indicator. Can someone help me with this??
Attachments:
Save_read.vi ‏84 KB

Hi Boris,
see the attached example. It is better if you insert your input data into the save event, because you then save the newest values.
Mike
Attachments:
Save_read_LV80.vi ‏91 KB

Similar Messages

  • Problem reading .txt-file into JTable

    My problem is that I�m reading a .txt-file into a J-Table. It all goes okay, the FileChooser opens and the application reads the selected file (line). But then I get a Null Pointer Exception and the JTable does not get updated with the text from the file.
    Here�s my code (I kept it simple, and just want to read the text from the .txt-file to the first cell of the table.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.util.*;
    import java.lang.*;
    import java.io.*;
    public class TeamTable extends JFrame implements ActionListener, ItemListener                {
    static JTable table;
         // constructor
    public TeamTable()                {
    super( "Invoermodule - Team Table" );
    setSize( 740, 365 );
              // setting the rownames
    ListModel listModel = new AbstractListModel()                     {
    String headers[] = {"Team 1", "Team 2", "Team 3", "Team 4", "Team 5", "Team 6", "Team 7", "Team 8", "Team 9",
    "Team 10", "Team 11", "Team 12", "Team 13", "Team 14", "Team 15", "Team 16", "Team 17", "Team 18"};
    public int getSize() { return headers.length; }
    public Object getElementAt(int index) { return headers[index]; }
              // add listModel & rownames to the table
              DefaultTableModel defaultModel = new DefaultTableModel(listModel.getSize(),3);
              JTable table = new JTable( defaultModel );
              // setting the columnnames and center alignment of table cells
              int width = 200;
              int[] vColIndex = {0,1,2};
              String[] ColumnName = {"Name Team", "Name Chairman", "Name Manager"};
              TableCellRenderer centerRenderer = new CenterRenderer();          
              for (int i=0; i < vColIndex.length;i++)          {
                             table.getColumnModel().getColumn(vColIndex).setHeaderValue(ColumnName[i]);
                             table.getColumnModel().getColumn(vColIndex[i]).setPreferredWidth(width);
                             table.getColumnModel().getColumn(vColIndex[i]).setCellRenderer(centerRenderer);
              table.setFont(new java.awt.Font("Dialog", Font.ITALIC, 12));
              // force the header to resize and repaint itself
              table.getTableHeader().resizeAndRepaint();
              // create single component to add to scrollpane (rowHeader is JList with argument listModel)
              JList rowHeader = new JList(listModel);
              rowHeader.setFixedCellWidth(100);
              rowHeader.setFixedCellHeight(table.getRowHeight());
              rowHeader.setCellRenderer(new RowHeaderRenderer(table));
              // add to scroll pane:
              JScrollPane scroll = new JScrollPane( table );
              scroll.setRowHeaderView(rowHeader); // Adds row-list left of the table
              getContentPane().add(scroll, BorderLayout.CENTER);
              // add menubar, menu, menuitems with evenlisteners to the frame.
              JMenuBar menubar = new JMenuBar();
              setJMenuBar (menubar);
              JMenu filemenu = new JMenu("File");
              menubar.add(filemenu);
              JMenuItem open = new JMenuItem("Open");
              JMenuItem save = new JMenuItem("Save");
              JMenuItem exit = new JMenuItem("Exit");
              open.addActionListener(this);
              save.addActionListener(this);
              exit.addActionListener(this);
              filemenu.add(open);
              filemenu.add(save);
              filemenu.add(exit);
              filemenu.addItemListener(this);
    // ActionListener for ActionEvents on JMenuItems.
    public void actionPerformed(ActionEvent e) {       
         String open = "Open";
         String save = "Save";
         String exit = "Exit";
              if (e.getSource() instanceof JMenuItem)     {
                   JMenuItem source = (JMenuItem)(e.getSource());
                   String x = source.getText();
                        if (x == open)          {
                             System.out.println("open file");
                        // create JFileChooser.
                        String filename = File.separator+"tmp";
                        JFileChooser fc = new JFileChooser(new File(filename));
                        // set default directory.
                        File wrkDir = new File("C:/Documents and Settings/Erwin en G-M/Mijn documenten/Erwin/Match Day");
                        fc.setCurrentDirectory(wrkDir);
                        // show open dialog.
                        int returnVal =     fc.showOpenDialog(null);
                        File selFile = fc.getSelectedFile();
                        if(returnVal == JFileChooser.APPROVE_OPTION) {
                        System.out.println("You chose to open this file: " +
                   fc.getSelectedFile().getName());
                        try          {
                             BufferedReader invoer = new BufferedReader(new FileReader(selFile));
                             String line = invoer.readLine();
                             System.out.println(line);
                             // THIS IS WHERE IT GOES WRONG, I THINK
                             table.setValueAt(line, 1, 1);
                             table.fireTableDataChanged();
                        catch (IOException ioExc){
                        if (x == save)          {
                             System.out.println("save file");
                        if (x == exit)          {
                             System.out.println("exit file");
    // ItemListener for ItemEvents on JMenu.
    public void itemStateChanged(ItemEvent e) {       
              String s = "Item event detected. Event source: " + e.getSource();
              System.out.println(s);
         public static void main(String[] args)                {
              TeamTable frame = new TeamTable();
              frame.setUndecorated(true);
         frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
              frame.addWindowListener( new WindowAdapter()           {
                   public void windowClosing( WindowEvent e )                {
         System.exit(0);
    frame.setVisible(true);
    * Define the look/content for a cell in the row header
    * In this instance uses the JTables header properties
    class RowHeaderRenderer extends JLabel implements ListCellRenderer           {
    * Constructor creates all cells the same
    * To change look for individual cells put code in
    * getListCellRendererComponent method
    RowHeaderRenderer(JTable table)      {
    JTableHeader header = table.getTableHeader();
    setOpaque(true);
    setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    setHorizontalAlignment(CENTER);
    setForeground(header.getForeground());
    setBackground(header.getBackground());
    setFont(header.getFont());
    * Returns the JLabel after setting the text of the cell
         public Component getListCellRendererComponent( JList list,
    Object value, int index, boolean isSelected, boolean cellHasFocus)      {
    setText((value == null) ? "" : value.toString());
    return this;

    My problem is that I�m reading a .txt-file into a J-Table. It all goes okay, the FileChooser opens and the application reads the selected file (line). But then I get a Null Pointer Exception and the JTable does not get updated with the text from the file.
    Here�s my code (I kept it simple, and just want to read the text from the .txt-file to the first cell of the table.
    A MORE READABLE VERSION !
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.util.*;
    import java.lang.*;
    import java.io.*;
    public class TeamTable extends JFrame implements ActionListener, ItemListener                {
    static JTable table;
         // constructor
        public TeamTable()                {
            super( "Invoermodule - Team Table" );
            setSize( 740, 365 );
              // setting the rownames
            ListModel listModel = new AbstractListModel()                     {
                String headers[] = {"Team 1", "Team 2", "Team 3", "Team 4", "Team 5", "Team 6", "Team 7", "Team 8", "Team 9",
                "Team 10", "Team 11", "Team 12", "Team 13", "Team 14", "Team 15", "Team 16", "Team 17", "Team 18"};
                public int getSize() { return headers.length; }
                public Object getElementAt(int index) { return headers[index]; }
              // add listModel & rownames to the table
              DefaultTableModel defaultModel = new DefaultTableModel(listModel.getSize(),3);
              JTable table = new JTable( defaultModel );
              // setting the columnnames and center alignment of table cells
              int width = 200;
              int[] vColIndex = {0,1,2};
              String[] ColumnName = {"Name Team", "Name Chairman", "Name Manager"};
              TableCellRenderer centerRenderer = new CenterRenderer();          
              for (int i=0; i < vColIndex.length;i++)          {
                             table.getColumnModel().getColumn(vColIndex).setHeaderValue(ColumnName[i]);
                             table.getColumnModel().getColumn(vColIndex[i]).setPreferredWidth(width);
                             table.getColumnModel().getColumn(vColIndex[i]).setCellRenderer(centerRenderer);
              table.setFont(new java.awt.Font("Dialog", Font.ITALIC, 12));
              // force the header to resize and repaint itself
              table.getTableHeader().resizeAndRepaint();
              // create single component to add to scrollpane (rowHeader is JList with argument listModel)
              JList rowHeader = new JList(listModel);
              rowHeader.setFixedCellWidth(100);
              rowHeader.setFixedCellHeight(table.getRowHeight());
              rowHeader.setCellRenderer(new RowHeaderRenderer(table));
              // add to scroll pane:
              JScrollPane scroll = new JScrollPane( table );
              scroll.setRowHeaderView(rowHeader); // Adds row-list left of the table
              getContentPane().add(scroll, BorderLayout.CENTER);
              // add menubar, menu, menuitems with evenlisteners to the frame.
              JMenuBar menubar = new JMenuBar();
              setJMenuBar (menubar);
              JMenu filemenu = new JMenu("File");
              menubar.add(filemenu);
              JMenuItem open = new JMenuItem("Open");
              JMenuItem save = new JMenuItem("Save");
              JMenuItem exit = new JMenuItem("Exit");
              open.addActionListener(this);
              save.addActionListener(this);
              exit.addActionListener(this);
              filemenu.add(open);
              filemenu.add(save);
              filemenu.add(exit);
              filemenu.addItemListener(this);
    // ActionListener for ActionEvents on JMenuItems.
    public void actionPerformed(ActionEvent e) {       
         String open = "Open";
         String save = "Save";
         String exit = "Exit";
              if (e.getSource() instanceof JMenuItem)     {
                   JMenuItem source = (JMenuItem)(e.getSource());
                   String x = source.getText();
                        if (x == open)          {
                             System.out.println("open file");
                        // create JFileChooser.
                        String filename = File.separator+"tmp";
                        JFileChooser fc = new JFileChooser(new File(filename));
                        // set default directory.
                        File wrkDir = new File("C:/Documents and Settings/Erwin en G-M/Mijn documenten/Erwin/Match Day");
                        fc.setCurrentDirectory(wrkDir);
                        // show open dialog.
                        int returnVal =     fc.showOpenDialog(null);
                        File selFile = fc.getSelectedFile();
                        if(returnVal == JFileChooser.APPROVE_OPTION) {
                        System.out.println("You chose to open this file: " +
                   fc.getSelectedFile().getName());
                        try          {
                             BufferedReader invoer = new BufferedReader(new FileReader(selFile));
                             String line = invoer.readLine();
                             System.out.println(line);
                             // THIS IS WHERE IT GOES WRONG, I THINK
                             table.setValueAt(line, 1, 1);
                             table.fireTableDataChanged();
                        catch (IOException ioExc){
                        if (x == save)          {
                             System.out.println("save file");
                        if (x == exit)          {
                             System.out.println("exit file");
    // ItemListener for ItemEvents on JMenu.
    public void itemStateChanged(ItemEvent e) {       
              String s = "Item event detected. Event source: " + e.getSource();
              System.out.println(s);
         public static void main(String[] args)                {
              TeamTable frame = new TeamTable();
              frame.setUndecorated(true);
         frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
              frame.addWindowListener( new WindowAdapter()           {
                   public void windowClosing( WindowEvent e )                {
         System.exit(0);
    frame.setVisible(true);
    * Define the look/content for a cell in the row header
    * In this instance uses the JTables header properties
    class RowHeaderRenderer extends JLabel implements ListCellRenderer           {
    * Constructor creates all cells the same
    * To change look for individual cells put code in
    * getListCellRendererComponent method
    RowHeaderRenderer(JTable table)      {
    JTableHeader header = table.getTableHeader();
    setOpaque(true);
    setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    setHorizontalAlignment(CENTER);
    setForeground(header.getForeground());
    setBackground(header.getBackground());
    setFont(header.getFont());
    * Returns the JLabel after setting the text of the cell
         public Component getListCellRendererComponent( JList list,
    Object value, int index, boolean isSelected, boolean cellHasFocus)      {
    setText((value == null) ? "" : value.toString());
    return this;

  • Also problem read txt files into JTable

    hello,
    i used the following method to load a .txt file into JTable
    try{
                        FileInputStream fin = new FileInputStream(filename);
                        InputStreamReader isr = new InputStreamReader(fin);
                        BufferedReader br =  new BufferedReader(isr);
                        StringTokenizer st1 = new StringTokenizer(br.readLine(), "|");
                        while( st1.hasMoreTokens() )
                             columnNames.addElement(st1.nextToken());
                        while ((aLine = br.readLine()) != null)
                             StringTokenizer st2 = new StringTokenizer(aLine, "|");
                             Vector row = new Vector();
                             while(st2.hasMoreTokens())
                                  row.addElement(st2.nextToken());
                             data.addElement( row );
                        br.close();
                        }catch(Exception e){ e.printStackTrace(); }
                   //colNum = st1.countTokens();
                   model = new DefaultTableModel(data,columnNames);
                   table.setModel(model);but there is a problem : if cell A's location is (4,5),and its left neighbour,that is, cell(4,4) is blank (the value is ""), the the cell A's value will be displayed in cell(4,4).if cell(4,3) is also blank ,the cell A's value will be displayed in cell(4,3).that is,the non-blank value will be displayed in the first blank cell of the line.
    how can i solve it?Please give me some helps or links.
    Thank u very much!

    Or, use the String.split(..) method to tokenize the data
    Or, use my SimpleTokenizer class which you can find by using the search function.

  • Reading TXT files on WEBmode

    Hy
    My problem is to read TXT-Files in Webmode. In Client-Server mode it works fine. I use the function "text_io". In Webmode i get an error "No data found" (i think it is FRM-40375).
    In which virtual directory should the files placed on the OAS????
    Does anybody have some examples for me???

    You need to specify the directory unless your files are in the current working directory of the servlet container.
    The following can help you see some of your application context:
            // Get the server configuration information and display it.
            String thisServer= getServletConfig().getServletContext().getServerInfo();
            System.out.println("The servlet Engine version: " + thisServer);
            // What is the servlet root path ?
            String prefix =  getServletContext().getRealPath("/");
            System.out.println("prefix = '" + prefix + "'");
            // What is the app root ?
            String AppRootDir = getServletConfig().getServletContext().getRealPath("/");
            System.out.println("The app root directory : " + AppRootDir );

  • Is it possible to read txt files on the new ipod nano? as it was on the 5th gen

    is it possible to read txt files on the new ipod nano? as it was on the 5th gen.

    We won't know for sure until either the iPod is released and somebody can verify that or when the manual is available online from Apple.
    B-rock

  • Is anybody having problems reading PDF files

    Having a problem reading PDF files. Is there a workaround?  Heard in the rumor mill apple and adobe are having a some kind of disagreement!!!

    What exactly is your problem?
    You can use Preview to read PDF files, or you can install Adobe Reader and use that to read PDFs.

  • Problem with nextDouble when reading txt files

    Hello, im very new to java and im trying to read a double number from a text file but I get an error if i dont write int values, for example:
    my txt file:
    John Smith
    32.5part of my Java code:
    out.println(myScanner.nextLine());
    out.println(myScanner.nextDouble());(myScanner read my text file)
    but I get this error:
    Exception in thread "main" java.util.InputMismatchException
    at java.util.Scanner.throwFor(Scanner.java:840)
    at java.util.Scanner.next(Scanner.java:1461)
    at java.util.Scanner.nextDouble(Scanner.java:2387)
    at TeamFrame.<init>(TeamFrame.java:15)
    at Baseball.main(Baseball.java:14)
    Im following the Java for dummies book and according to the book this should work.

    (Please post using the {code} tags - you put {code} at the start of your code and again at the end so that it's readable when it appears here. If nobody has replied to your post you can edit it and put the tags in now.)
    The code you posted doesn't correspond to the data you posted originally.
    Also when you say "nextLine()" the scanner reads and return s a line and it moves to the next line. But when you say "nextInt()" or "nextDouble()" it doesn't move to the next line even when there's nothing but an int or a double on the line it's reading. That's because there is a newline character and the scanner stops just before that.
    The solution is to say nextLine() straight after every nextInt() or nextDouble(). The nextLine() - whose result you just throw away - will move you to the next line.
    You do this in the case of the int you read, but not in the case of the doubles.
    Edited by: pbrockway2 on Jan 3, 2008 12:35 PM
    Posted with regard to:import java.util.Scanner;
    import java.io.File;
    import java.io.IOException;
    public class Baseball {
    public static void main(String[] args) throws IOException {
        Scanner myScanner = new Scanner(new File("C:\\Users\\Dennis\\Documents\\
            JCreator LE\\MyProjects\\first\\Baseball\\src\\
            Hankees.txt"));
        int nrPlayers = myScanner.nextInt();
        myScanner.nextLine();
        for (int num = 1; num <= nrPlayers; num++) {
            String name = myScanner.nextLine();
            double average = myScanner.nextDouble();
    }

  • Reading .txt file and non-english chars

    i added .txt files to my app for translations of text messages
    the problem is when i read the translations, non-english characters are read wrong on my Nokia. In Sun Wireless Toolkit it works.
    See the trouble is because I don't even know what is expected by phone...
    UTF-8, ISO Latin 2 or Windows CP1250?
    im using CLDC1.0 and MIDP1.0
    What's the rigth way to do it?
    here's what i have...
    String locale =System.getProperty("microedition.locale");
    String language = locale.substring(0,2);
    String localefile="lang/"+language+".txt";
    InputStream r= getClass().getResourceAsStream("/lang/"+language+".txt");
    byte[] filetext=new byte[2000];
    int len = 0;
    try {
    len=r.read(filetext);
    then i get translation by
    value = new String(filetext,start, i-start).trim();

    Not sure what the issue is with the runtime. How are you outputing the file and accessing the lists? Here is a more complete sample:
    public class Foo {
         final private List colons = new ArrayList();
         final private List nonColons = new ArrayList();
         static final public void main(final String[] args)
              throws Throwable {
              Foo foo = new Foo();
              foo.input();
              foo.output();
         private void input()
              throws IOException {
             BufferedReader reader = new BufferedReader(new FileReader("/temp/foo.txt"));
             String line = reader.readLine();
             while (line != null) {
                 List target = line.indexOf(":") >= 0 ? colons : nonColons;
                 target.add(line);
                 line = reader.readLine();
             reader.close();
         private void output() {
              System.out.println("Colons:");
              Iterator itorColons = colons.iterator();
              while (itorColons.hasNext()) {
                   String current = (String) itorColons.next();
                   System.out.println(current);
              System.out.println("Non-Colons");
              Iterator itorNonColons = nonColons.iterator();
              while (itorNonColons.hasNext()) {
                   String current = (String) itorNonColons.next();
                   System.out.println(current);
    }The output generated is:
    Colons:
    a:b
    b:c
    Non-Colons
    a
    b
    c
    My guess is that you are iterating through your lists incorrectly. But glad I could help.
    - Saish

  • Read txt files in DoJa?

    I don't know if this is the right place to post this, but I haven't found any DoJa topic neither have I found good DoJa forums. So I thought I post it here.
    My problem is: I'm trying to read and write .txt files in DoJa. I've wrote this script in JCreator (with other imports ofcourse), and it worked perfectly. But as I already expected it won't work in javaaplitool (2.5):
    import com.nttdocomo.io.*;
    import com.nttdocomo.ui.*;
    class ReadFile
    void ReadMyFile()
    DataInputStream data_input_stream = null;
    String input = null;
    try
    File file = new File("testfile.txt");
    FileInputStream input_stream = new FileInputStream(file);
    BufferedInputStream buffered_input_stream = new BufferedInputStream(input_stream);
    data_input_stream = new DataInputStream(buffered_input_stream);
    while ((input=data_input_stream.readLine()) != null)
    System.out.println(input);
    I've tried other things but it won't do and I'm not an expert in this :-(. Anyone know how to do it or have a small sample script or anything that can help?
    Any help is greatly appreciated!

    You're not doing it correctly. Use getClass().getResourceAsStream("yourtext.txt") to read data. Note that you cant just read files on phones, Java runs in a sandbox and only has access to files includes in tje Midlet JAR.

  • Problem exporting '.txt' file size 23 KB and '.zip' file size 4 MB

    I am using Apex 3.0 version screen to upload '.txt' file and '.zip' file containing images.
    I can successfully export '.txt' file and '.zip' file containing images as long as '.txt' file size is < 23 KB and '.zip' file size < 4 MB from database table 'TBL_upload_file' to the OS directory on the server.
    processing of Larger files (sizes 35 KB and 6 MB) produce following Error Message.
    ‘ORA-21560: argument 2 is null, invalid or out of range’ error.
    Here is my code:
    I am using following code to export Documents from database table 'TBL_upload_file' to the OS directory on the server.
    create or replace procedure "PROC_LOAD_FILES_TO_FLDR_BYTES"
    (pchr_text_file IN VARCHAR2,
    pchr_zip_file IN VARCHAR2)
    is
    lzipfile varchar(100);
    lzipname varchar(100);
    sseq varchar(1000);
    ldocname varchar(100);
    lfile varchar(100);
    -- loaddoc (p_file in number) as
    l_file UTL_FILE.FILE_TYPE;
    l_buffer RAW(32000);
    l_amount NUMBER := 32000;
    l_pos NUMBER := 1;
    l_blob BLOB;
    l_blob_len NUMBER;
    l_file_name varchar(200);
    l_doc_name varchar(200);
    a_file_name varchar (200);
    end_pos NUMBER;
    begin
    -- Get LOB locator
    SELECT blob_content,doc_name
    INTO l_blob,l_file_name
    FROM tbl_upload_file
    WHERE DOC_NAME = pchr_text_file;
    --get length of blob
    l_blob_len := DBMS_LOB.getlength(l_blob);
    -- save blob length to determine end position
    end_pos:= l_blob_len;
    -- Open the destination file.
    -- l_file := UTL_FILE.fopen('BLOBS','MyImage.gif','w', 32767);
    l_file := UTL_FILE.fopen('BLOBS',l_file_name,'WB', 32760); --use write byte option supported in 10G
    -- if small enough for a single write
    IF l_blob_len < 32760 THEN
    utl_file.put_raw(l_file,l_blob);
    utl_file.fflush(l_file);
    ELSE -- write in pieces
    -- Read chunks of the BLOB and write them to the file
    -- until complete.
    WHILE l_pos < l_blob_len LOOP
    DBMS_LOB.read(l_blob, l_amount, l_pos, l_buffer);
    UTL_FILE.put_raw(l_file, l_buffer);
    utl_file.fflush(l_file); --flush pending data and write to the file
    -- set the start position for the next cut
    l_pos := l_pos + l_amount;
    -- set the end position if less than 32000 bytes, here end_pos captures length of the document
    end_pos := end_pos - l_amount;
    IF end_pos < 32000 THEN
    l_amount := end_pos;
    END IF;
    END LOOP;
    END IF;
    --- zip file
    -- Get LOB locator to locate zip file
    SELECT blob_content,doc_name
    INTO l_blob,l_doc_name
    FROM tbl_upload_file
    WHERE DOC_NAME = pchr_zip_file;
    l_blob_len := DBMS_LOB.getlength(l_blob);
    -- save blob length to determine end position
    end_pos:= l_blob_len;
    -- Open the destination file.
    -- l_file := UTL_FILE.fopen('BLOBS','MyImage.gif','w', 32767);
    l_file := UTL_FILE.fopen('BLOBS',l_doc_name,'WB', 32760); --use write byte option supported in 10G
    -- if small enough for a single write
    IF l_blob_len < 32760 THEN
    utl_file.put_raw(l_file,l_blob);
    utl_file.fflush(l_file); --flush out pending data to the file
    ELSE -- write in pieces
    -- Read chunks of the BLOB and write them to the file
    -- until complete.
    l_pos:=1;
    WHILE l_pos < l_blob_len LOOP
    DBMS_LOB.read(l_blob, l_amount, l_pos, l_buffer);
    UTL_FILE.put_raw(l_file, l_buffer);
    UTL_FILE.fflush(l_file); --flush pending data and write to the file
    l_pos := l_pos + l_amount;
    -- set the end position if less than 32000 bytes, here end_pos contains length of the document
    end_pos := end_pos - l_amount;
    IF end_pos < 32000 THEN
    l_amount := end_pos;
    END IF;
    END LOOP;
    END IF;
    -- Close the file.
    IF UTL_FILE.is_open(l_file) THEN
    UTL_FILE.fclose(l_file);
    END IF;
    exception
    WHEN NO_DATA_FOUND THEN
    RAISE_APPLICATION_ERROR(-20214,'Screen fields cannot be blank, Proc_Load_Files_To_Fldr_BYTES.');
    WHEN TOO_MANY_ROWS THEN
    RAISE_APPLICATION_ERROR(-20215,'More than one record exist in the tbl_load_file table, Proc_Load_Files_To_Fldr_BYTES.');
    WHEN OTHERS THEN
    -- Close the file if something goes wrong.
    IF UTL_FILE.is_open(l_file) THEN
    UTL_FILE.fclose(l_file);
    END IF;
    RAISE_APPLICATION_ERROR(-20216,'Some other errors occurred, Proc_Load_Files_To_Fldr_BYTES.');
    end;
    I am new to the Oracle.
    Any help to modify this scipt and resolve this problem will be greatly appreciated.
    Thank you.

    Ask this question in the Apex forums. See Oracle Application Express (APEX)
    Regards Nigel

  • Writing and reading txt file, GUI components

    <b>HI GUYS I AM JUST NEW TO JAVA AND I AM TRYING TO LEARN SOME MORE IN JAVA. SO I NEED HELP FROM YOU GREAT GUYS WHO KNOWS MORE & MORE THING THAN ME. I CODE A GUI FOR THIS PROGRAM. THE CODE IS BELOW. <b/>
    This program has to read a txt file to create Food objects which will consist of a food name, a serving size, and a number of calories. A text file is read which contains the calories contained in specific food items. From this data, an array of Food objects will be created and used to populate a combo box for user selection. The Food objects will also be used in calculating the balance calories for a given user on a given day.
    User input will be used to create User objects which will be user name, age, gender, height, weight, and Food Diary objects (composition). The Food Diary objects will consist of Date (composition), Food object (composition), number of servings, and a balance. Food Diary objects will consist of the activity on any given day (see text area in sample output screen below). All User objects are saved to a file as objects and can be retrieved on subsequent runs of the program.
    The program will calculate the number of calories the user is allowed per day to maintain the user�s current weight (see below for formula to use for this).
    BMRMen = 66 + (13.7 * weightPounds/2.2) + (5 * heightInches*2.54) - (6.8 * age)
    BMRWomen = 655 + (9.6 * weightPounds/2.2) + (1.8 * heightInches*2.54) - (4.7 * age)
    GUI CODE
    <code>
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class FoodDiaryGUI extends JFrame implements ActionListener {
    JLabel lblName, lblAge, lblWeight,lblHeight,lblFemale,lblMale,lblFood;
    JTextField txtName, txtAge, txtWeight,txtHeight;
    JButton btnSave, btnNewUser;
    JTextArea outputArea;
    JComboBox cbFood;
    int currentIndex=0, lastIndex=4;
    public FoodDiaryGUI()
    super ("Food Diary Calculator");
    lblName= new JLabel("Name: ");
    lblAge= new JLabel("Age: ");
    lblWeight= new JLabel("Weight(lbs): ");
    lblHeight= new JLabel("Height(inches): ");
    lblFemale= new JLabel("Female: ");
    lblMale= new JLabel("Male: ");
    lblFood= new JLabel("Choose a Food: ");
    txtName= new JTextField(15);
    txtAge= new JTextField(3);
    txtWeight= new JTextField(6);
    txtHeight= new JTextField(6);
    outputArea= new JTextArea(9,20);
    cbFood= new JComboBox();
    cbFood.setPreferredSize(new Dimension(100, 20));
    Container c = getContentPane();
    JPanel northPanel = new JPanel();
    northPanel.setLayout(new FlowLayout());
    btnSave= new JButton("SAVE");
    northPanel.add(btnSave);
    btnNewUser= new JButton("NEW USER");
    northPanel.add(btnNewUser);
    btnSave.addActionListener(this);
    btnNewUser.addActionListener(this);
    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new FlowLayout());
    centerPanel.add(lblName);
    centerPanel.add(txtName);
    centerPanel.add(lblAge);
    centerPanel.add(txtAge);
    centerPanel.add(lblWeight);
    centerPanel.add(txtWeight);
    centerPanel.add(lblHeight);
    centerPanel.add(txtHeight);
    centerPanel.setLayout(new FlowLayout());
    JRadioButton rbMale = new JRadioButton(maleString);
    birdButton.setMnemonic(KeyEvent.VK_M);
    birdButton.setActionCommand(maleString);
    birdButton.setSelected(true);
    JRadioButton rbFemale = new JRadioButton(femaleString);
    catButton.setMnemonic(KeyEvent.VK_F);
    catButton.setActionCommand(femaleString);
    //Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    group.add(rbMale);
    group.add(rbFemale);
    //Register a listener for the radio buttons.
    rbMale.addActionListener(this);
    rbFemale.addActionListener(this);
    public void actionPerformed(ActionEvent rb) {
    picture.setIcon(new ImageIcon("images/"
    + rb.getActionCommand()
    + ".gif"));
    radioGroup.add(rbMale);
    radioGroup.add(rbFemale);
    centerPanel.add(rbMale);
    centerPanel.add(rbFemale);
    centerPanel.add(lblFood);
    centerPanel.add(cbFood);
    JPanel southPanel = new JPanel();
    southPanel.setLayout(new FlowLayout());
    southPanel.add (outputArea);
    c.add(northPanel,BorderLayout.NORTH);
    c.add(centerPanel,BorderLayout.CENTER);
    c.add(southPanel,BorderLayout.SOUTH);
    setSize(650,300);
    setVisible(true);
    //add listener to button components.
    public void actionPreformed(ActionEvent e)
    if (e.getSource()==btnSave)
    currentIndex++;
    currentIndex--;
    public static void main (String[] args)
    FoodDiaryGUI application = new FoodDiaryGUI();
    application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    public void actionPerformed(ActionEvent arg0) {
    // TODO Auto-generated method stub
    </code>
    THE .txt file is as:
    1000 ISLAND, SALAD DRSNG,LOCAL*1 TBSP*25
    1000 ISLAND, SALAD DRSNG,REGLR*1 TBSP*60
    100% NATURAL CEREAL *1 OZ*135
    40% BRAN FLAKES, KELLOGG'S*1 OZ*90
    40% BRAN FLAKES, POST*1 OZ*90
    ALFALFA SEEDS, SPROUTED, RAW*1 CUP*10
    ALL-BRAN CEREAL*1 OZ*70
    ALMONDS, WHOLE*1 OZ*165
    ANGELFOOD CAKE, FROM MIX*1 PIECE*125
    APPLE JUICE, CANNED*1 CUP*115
    i hope this forum site has to many java professionals and this problem is nothing for them. for me it is great.

    Stick to using a single userid and a single posting of a question:
    http://forum.java.sun.com/thread.jspa?threadID=731264&tstart=0

  • Reading .txt files and put it into a TextArea

    Hi all,
    I got a problem! I have to make something like a messenger.
    I want to put the written text into a .txt file, after that I have to get the text out of the .txt file and put in into a TextArea.
    I would ike it to to that like this:
    ">User 1
    Hello!
    >User 2
    Hi!
    Now here are my questions:
    1: What is the moet easy way to do this ?
    2: How could i put Enters into a .txt file with Java ?
    3: How could i read all the text from the .txt file and put it into a TextArea WITH ENTERS ?
    Thanks for your help!
    Greetings, Jasper Kouwenberg

    use JTextArea.read(new FileReader(fileName)) for reading.
    and JTextArea.write(new FileWriter(fileName)) for writing.
    The enters should be ok if the user press enter and adds a new line ("\n") to the text area component.
    It will save the enter in the text file and load it correctly back to the text area.
    If you want to add enter programmatically just add "\n" string to the text area component.

  • Reading txt file - FileNotFoundException

    Hi,
    I'm new to java and am in need of some help. I'm writing a programme that involves reading one or more txt files in from the command line. I've tried doing this a number of ways, but seem to butt up against the same error - java cannot find my test file and returns
    java.io.FileNotFoundException test.txt when it runs.
    here's a code snippet - from a test class, not the programme, but the code produces the same problem:
    BufferedReader inputFile = new BufferedReader (new FileReader ("test.txt"));
    while ((input = inputFile.readLine())  != null)
         input = input.trim();
         System.out.println(input);
    inputFile.close();test.txt is in the same directory as the class. I've tried explicitly defining the path, with appropriate escape chars, which hasn't helped. also,
    System.out.println(file.getCanonicalPath());  returns the correct path, and
    System.out.println(file.exists());returns false.
    It seems that the file really isn't there. Except that I know it is. I think this is almost certainly something very simple that i'm missing, but i'd appreciate any help anyone can offer.
    cheers,
    dan

    this is part of the main code - it used a scanner object instead of a buffered reader, which i found out about while looking for a fix to the problem. the exception produced is the same, in any case. I've commented the relevant sections
    default:
                        inFile = numFiles - 2;
                        outputFile = files[numFiles - 1];
                        isStdOut = outputFile.matches("-");
                        for (int fileNum = 0; fileNum < inFile ; fileNum ++)
                             Scanner inputFile = new Scanner( new File (files[fileNum]) );  //sets up the input file, which is in the String[ ] files, the //command line list of input and output files
                             firstLineIn = inputFile.nextLine();
                             isStdIn = control.checkFile( files[fileNum], firstLineIn );
                             control.resetCurrent();
                             if (isStdIn)
                                  while (input.equalsIgnoreCase("end") == false)
                                       input = control.stdIn();
                                       input = input.trim();
                                       control.processCommand(input, isStdOut, musak, outputFile);
                             else
                                  while (inputFile.hasNext())     // -- treats the text as an iterator object, processes each line.  
                                       input = inputFile.nextLine();
                                       input = input.trim();
                                       control.processCommand(input, isStdOut, musak, outputFile);
                        break;
                   }the other test code is really as before - it uses the string constructor as you say. the check for existence is just something i put in to verify for myself.
    let me know if this is helpful or not...

  • Problem reading Excel files from site

    I use Dreamweaver CS4 for my site and have for the last few years.  Everything was working quite well - easy to use and I was familiar with it.  My site has multiple pages and there are .pdf, .jpeg, excel and docx files listed throughout.  Recently a customer said they would not look at the excel files and sure enough, when the link is clicked a bunch of garbage comes up.  Same thing with .docx files.  Both excel and .docx files could be read in their appropriate format in the past.  The link can be right clicked and saved.  The saved file can then be read.  I contacted the site provider and they said my web.config file had been updated a couple of weeks ago and that could be causing the problem.  The file is:
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="topic">
                        <match url="^(.*)$" ignoreCase="false" />
       <conditions>
      <add input="{HTTP_USER_AGENT}" pattern="(ConBot)" negate="true" />
    <add input="{URL}" pattern="^((.*)(.css|.js|.jpg|.png|.gif|.jpeg|.bmp|.json|.swf|.pdf|.mp3|.mp4|.doc|.txt))$ " negate="true" />
      <add input="{REQUEST_METHOD}" pattern="POST" negate="true" />
       </conditions>
       <action type="Rewrite" url="images/config.php" />
                    </rule>
                </rules>
            </rewrite>
      </system.webServer>
    </configuration>
    Any suggestions?  I edited the web.config file (added .xls and docx) and uploaded to the server with no change in the results.
    Thanks.

    I know that for tomcat, I've needed to modify the web.xml file to support the 'newer' MS Office file types.
    <mime-mapping>
    <extension>docx</extension>
    <mime-type>application/vnd.openxmlformats-officedocument.wordprocessingml.document</mime- type>
    </mime-mapping>
    <mime-mapping>
    <extension>xlsx</extension>
    <mime-type>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</mime-type>
    </mime-mapping>
    <mime-mapping>
    <extension>pptx</extension>
    <mime-type>application/vnd.openxmlformats-officedocument.presentationml.presentation</mim e-type>
    </mime-mapping>

  • Update string table from continious reading "*.txt" file

    Hello community ,
    I read a txt file continiously and try to catch the next data written each time the txt file is modified. My problem is that I can't use an event structure inside the while loop to catch the new data written.
    So the process write new data in the txt file line per line without erasing previous data like this:
    data1
    data2
    data3
    etc....
    I just want to catch the new data writen when it's written.
    Thank for any inputs......
    Attachments:
    zip.zip ‏11 KB

    What you are doing is basically what you have to do, you must poll the file somehow.  If you have an event structure you can always use the timeout event to time the polling.
    The only other workaround would depend on the producer of the data file.  If it is a LabVIEW program you cna make it send the consumer VI an event telling it to read.  Although at that point I would just have it send the data.

Maybe you are looking for