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.

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;

  • Reading .txt file into char array, file not found error. (Basic IO)

    Iv been having some trouble with reading characters from a text file into a char array. I havnt been learning io for very long but i think im getting the hang of it. Reading and writing raw bytes
    and things like that. But i wanted to try using java.io.FileReader to read characters for a change and im having problems with file not found errors. here is the code.
    try
    File theFile = new File("Mr.DocumentReadMe.txt");
    String path = theFile.getCanonicalPath();
    FileReader readMe = new FileReader(path);
    char buffer[] = new char[(int)theFile.length()];
    int readData = 0;
    while(readData != -1)
    readData = readMe.read(buffer);
    jEditorPane1.setText(String.valueOf(buffer));
    catch(Exception e)
    JOptionPane.showMessageDialog(null, e,
    "Error!", JOptionPane.ERROR_MESSAGE);
    The error is: java.io.FileNotFoundException: C:\Users\Kaylan\Documents\NetBeansProjects\Mr.Document\dist\Mr.DocumentReadMe.txt (The system cannot find the file specified)
    The text file is saved in the projects dist folder. I have tried saving it elsewhere and get the same error with a different pathname.
    I can use JFileChooser to get a file and read it into a char array with no problem, why doesnt it work when i specify the path manually in the code?

    Well the file clearly isn't there. Maybe it has a .txt.txt extensionthat Windows is kindly hiding from you - check its Properties.
    But:
    String path = theFile.getCanonicalPath();
    FileReader readMe = new FileReader(path);You don't need all that. Just:
    FileReader readMe = new FileReader(theFile);And:
    char buffer[] = new char[(int)theFile.length()];You don't need a buffer the size of the file, this is bad practice. Use 8192 or whatever.
    while(readData != -1)
    readData = readMe.read(buffer);
    }That doesn't make sense. Read the data into the buffer and repeat until you get EOF? and do nothing with the contents of the buffer? The canonical read loop in Java goes like this:
    while ((count = in.read(buffer)) > 0)
      out.write(buffer, 0, count); // or do something else with buffer[0..count-1].
    jEditorPane1.setText(String.valueOf(buffer));Bzzt. That won't give you the content of 'buffer'. Use new String(buffer, 0, count) at least.

  • 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

  • Problem reading dng files into Photoshop CS6

    Why can't I read dng files from a canon 5dmk2 from ACR8.1 into Photoshop cs6?

    I converted the CR2 files from the Canon5dmk2 into dng using the Adobe DNG converter.
    In Photoshop CS3 I can read these dng files into Adobe Camera Raw and then export them into Photoshop. No problem.
    I have just installed Photoshop CS6. I can read the dng files into Adobe Camera Raw (v8.1) without a problem. However the file is then corrupted when I try to export it into CS6.
    Strangely, I have similar files converted from CR2 to DNG for a Canon 1100D and these read without problem via ACR into both Photoshop CS3 and CS6.
    The problem is that Photoshop CS6 will not read dng files from a Canon 5dmk2.

  • How to read .txt file into a 2D array ? Pls help !

    I have a .txt file with contents as shown :
    1 0 1 0 1 0 1 0
    1 0 1 1 1 0 0 1
    1 0 1 0 1 0 1 0
    1 0 1 1 1 0 0 1
    1 0 1 1 1 0 0 1
    1 0 1 1 1 0 0 1
    1 0 1 1 1 0 0 1
    1 0 1 1 1 0 0 1
    1 0 1 1 1 0 0 1
    1 0 1 1 1 0 0 1
    and so on...until 10 samples in total.
    How do I create a class which has a method (which I can call later) to put all those binary digits in a 2-D array ? The method should automatically extract data from the .txt file and put it into a 2-D array. How do I do that please ?
    Please help someone ? It's pretty urgent....:-(

    This one takes the cake: essentially the same question, cross-posted 11 times:
    http://forum.java.sun.com/thread.jsp?thread=560218&forum=57&message=2752602
    http://forum.java.sun.com/thread.jsp?thread=560219&forum=426&message=2752600
    http://forum.java.sun.com/thread.jsp?thread=560220&forum=31&message=2752599
    http://forum.java.sun.com/thread.jsp?thread=560220&forum=31&message=2752583
    http://forum.java.sun.com/thread.jsp?thread=560220&forum=31&message=2752519
    http://forum.java.sun.com/thread.jsp?thread=560219&forum=426&message=2752518
    http://forum.java.sun.com/thread.jsp?thread=560218&forum=57&message=2752517
    http://forum.java.sun.com/thread.jsp?thread=559967&forum=31&message=2750787
    http://forum.java.sun.com/thread.jsp?thread=559968&forum=57&message=2750767
    http://forum.java.sun.com/thread.jsp?thread=559967&forum=31&message=2750751
    http://forum.java.sun.com/thread.jsp?thread=559964&forum=426&message=2750734
    DON'T CROSS-POST! Send your question to one forum. You waste people's time
    doing anything else.
    How To Ask Questions The Smart Way

  • Reading Txt File into a GUI

    Hi,
    Direction on how to read a text file consisting of rows and columns with 1's and 0's into a GUI would be useful.
    I can ask user for filename and display the file in a DOS window but unsure of how I would use a text box to ask for a filename and then display the contents of it into the GUI.
    Im fairly new to Java, Where do I start?
    Thanks.

    Alternatively, take a look at this:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    class Editor extends JFrame
        private BorderLayout borderLayout1 = new BorderLayout();
        private JScrollPane jScrollPane1 = new JScrollPane();
        private JTextArea jTextArea1 = new JTextArea();
        private JMenuBar jMenuBar1 = new JMenuBar();
        private JMenu jMenu1 = new JMenu();
        private JMenuItem jMenuItem1 = new JMenuItem();
        private JMenuItem jMenuItem2 = new JMenuItem();
        public static void main(String[] args)
            Editor editor=new Editor();
            editor.setBounds(100,100,400,400);
            editor.setVisible(true);
        public Editor()
            try
                jbInit();
            catch(Exception e)
                e.printStackTrace();
            this.pack();
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        private void jbInit() throws Exception
            this.getContentPane().setLayout(borderLayout1);
            this.setJMenuBar(jMenuBar1);
            jMenu1.setText("File");
            jMenuItem1.setText("Open");
            jMenuItem1.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(ActionEvent e)
                    jMenuItem1_actionPerformed(e);
            jMenuItem2.setText("Save");
            jMenuItem2.addActionListener(new java.awt.event.ActionListener()
                public void actionPerformed(ActionEvent e)
                    jMenuItem2_actionPerformed(e);
            this.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
            jScrollPane1.getViewport().add(jTextArea1, null);
            jMenuBar1.add(jMenu1);
            jMenu1.add(jMenuItem1);
            jMenu1.add(jMenuItem2);
        void jMenuItem1_actionPerformed(ActionEvent e)
            JFileChooser fileSelectDialog=new JFileChooser();
            fileSelectDialog.setDialogTitle("Open file");
            fileSelectDialog.setFileSelectionMode(JFileChooser.FILES_ONLY);
            fileSelectDialog.setCurrentDirectory(new File("."));
            int result=fileSelectDialog.showDialog(this, null);
            if(result==fileSelectDialog.APPROVE_OPTION)
                File file=fileSelectDialog.getSelectedFile();
                if(file!=null)
                    try
                        FileInputStream fileInputStream=new FileInputStream(file);
                        byte[] data=new byte[(int)file.length()];
                        fileInputStream.read(data);
                        jTextArea1.setText(new String(data));
                    catch(IOException ex)
                        showExceptionMessage(ex);
        void jMenuItem2_actionPerformed(ActionEvent e)
            JFileChooser fileSelectDialog=new JFileChooser();
            fileSelectDialog.setDialogTitle("Save file");
            fileSelectDialog.setDialogType(JFileChooser.SAVE_DIALOG);
            fileSelectDialog.setFileSelectionMode(JFileChooser.FILES_ONLY);
            fileSelectDialog.setCurrentDirectory(new File("."));
            int result=fileSelectDialog.showDialog(this, null);
            if(result==fileSelectDialog.APPROVE_OPTION)
                File file=fileSelectDialog.getSelectedFile();
                if(file!=null)
                    try
                        FileOutputStream fileOutputStream=new FileOutputStream(file,false);
                        fileOutputStream.write(jTextArea1.getText().getBytes());
                    catch(IOException ex)
                        showExceptionMessage(ex);
        public void showExceptionMessage(Exception ex)
            StringWriter stringWriter=new StringWriter();
            PrintWriter printWriter=new PrintWriter(stringWriter);
            ex.printStackTrace(printWriter);
            JOptionPane.showMessageDialog(this,stringWriter.toString().replace('\t',' ').replace('\r',' '),"Exception!",JOptionPane.ERROR_MESSAGE);
    }

  • Reading entire txt file into memory?

    When you are using BufferedReader to read info into a buffer, that means you are reading the file into memory, correct? (Is that what buffer means?)
    I want to look for pattern matches in text files (about 1000 of them) using the regex utils. But I don't want to read and examine the text files line by line. I want to read in the entire text file into memory first and then look for the pattern matches. The text files generally don't exceed about 15K in size. I'm only going one file at a time, too, so this won't give me any out of memory errors, will it?
    And more importantly, how do I do it? I mean the "reading in the file" part only. I have my RegEx, I have my array of files to examine already. I just can't figure out the right code to use to read each file into memory before I look for pattern matches.
    Could someone help, please?

    When you are using BufferedReader to read info into a
    buffer, that means you are reading the file into
    memory, correct? (Is that what buffer means?)Yes.
    I want to look for pattern matches in text files
    (about 1000 of them) using the regex utils. But I
    don't want to read and examine the text files line by
    line.Why not?
    I want to read in the entire text file into
    memory first and then look for the pattern matches.Why?
    The text files generally don't exceed about 15K in
    size. I'm only going one file at a time, too, so
    this won't give me any out of memory errors, will
    it?Depends on how much memory you've given the VM and how much of that it's using already at the time you read the files, but in general, probably not a problem.
    And more importantly, how do I do it? I mean the
    "reading in the file" part only.Use BufferedReader to read line by line and then append each line (plus a newline, since BR.readLine() strips those off) to a StringBuilder.
    Or use a BufferedInputStream and and array that's as big as the file, and in a loop, try to read as much as is left into that array at an offset equal to how much has been read so far.
    I still think this is probably not a good approach though.

  • [CS3 JS]  Reading TXT file content into String

    Hello,
    I'm currently wanting to display a dialog box that has a dropdown menu containing all countries of the world.
    I have an external txt file that contains a list of all countries.
    I thought I would simply read-in the contents of the 'txt' file into a string and use it for displaying the list.
    For example
    i Instead of the usual:
    > var myLandMenu = dropdowns.add({stringList:["A", "B"...], selectedIndex:0});
    i I thought of doing something like:
    > var myLandList = ....? HELP ?....
    > var myLandMenu = dropdowns.add({stringList:myLandList, selectedIndex:0});
    Is this the way to do it?
    What would be the way to read in the text file content as a string?
    Thanks in advance,
    Lee

    > var myLandList = ....? HELP ?....
    > var myLandMenu = dropdowns.add({stringList:myLandList, selectedIndex:0});
    It's hard to tell from context, but myLandList needs to be an array of strings.
    If the file has one element per line, this would be one way of handling the
    conversion:
    var file = File("~/countries.txt");
    file.open("r");
    var str = file.read();
    file.close();
    var myLandList = str.split(/[\r\n]+/);
    And assuming that this is ScriptUI and not the older ID UI, the menu creation
    would look more like:
    var myLandMenu = dropdowns.add(bounds, myLandList);
    myLandMenu.items[0].selected = true;
    -X
    for photoshop scripting solutions of all sorts
    contact: [email protected]

  • Add .txt files into .zip file

    Hello friends,
    Any buddy knows how to add ".txt" files into ".zip" format through the ABAP code. 
    Thanks in advance.

    Hi Murali,
    You can use the method in the class CL_ABAP_GZIP to zip your file and then download it using GUI_DOWNLOAD.
    data: zip type ref to cl_abap_zip,
          result type xstring.
    create object zip.
    zip->add( name = some_file content = content ).
    result = zip->save( ).
    Also you can check this thread as well.
    How to Download data in Zip folder
    Re: UNZIP file from ABAP
    Hope this will help.
    Regards,
    Ferry Lianto
    Please reward points if helpful.

  • Convert .txt file into .xml file

    Hello,
    How do i convert an .txt file into an .xml file using labVIEW function?.
    Also i do i extract the header from the text file.
    My file format is mentioned in attached .txt file.
    Also I need to extract the header from the converted .xml file.
    Anticipating reply
    Attachments:
    Example.txt ‏1 KB

    There is no automatic mechanism for converting a .txt file to XML in any language. You have to define the XML schema and then write the code to generate the XML file. You could also read in your text file into some form of structure and then use the Flatten to XML functions to use the NI XML schema. If you need to use your own XML schema then you would need to use the XML Parser VIs to generate your XML file. Alternatively, you could use LabXML or JKI's EasyXML Toolkit.

  • How can I load a .TXT file into a dynamic text box?

    I am sure that many people know how to load a .txt file into
    a dynamic text box. But I do not. I want to be able to reference a
    txt file from the server into the text box. So that when I change
    the text file it changes in the flash movie without even editing
    the flash file itself. Thank you.

    http://www.oman3d.com/tutorials/flash/loading_external_text_bc/
    I think this is the simplest way to go :)

  • Question about reading csv file into internal table

    Some one (thanks those nice guys!) in this forum have suggested me to use FM KCD_CSV_FILE_TO_INTERN_CONVERT to read csv file into internal table. However, it can be used to read a local file only.
    I would like to ask how can I read a CSV file into internal table from files in application server?
    I can't simply use SPLIT as there may be comma in the content. e.g.
    "abc","aaa,ab",10,"bbc"
    My expected output:
    abc
    aaa,ab
    10
    bbb
    Thanks again for your help.

    Hi Gundam,
    Try this code. I have made a custom parser to read the details in the record and split them accordingly. I have also tested them with your provided test cases and it work fine.
    OPEN DATASET dsn FOR input IN TEXT MODE ENCODING DEFAULT.
    DO.
    READ DATASET dsn INTO record.
      PERFORM parser USING record.
    ENDDO.
    *DATA str(32) VALUE '"abc",10,"aaa,ab","bbc"'.
    *DATA str(32) VALUE '"abc","aaa,ab",10,"bbc"'.
    *DATA str(32) VALUE '"a,bc","aaaab",10,"bbc"'.
    *DATA str(32) VALUE '"abc","aaa,ab",10,"b,bc"'.
    *DATA str(32) VALUE '"abc","aaaab",10,"bbc"'.
    FORM parser USING str.
    DATA field(12).
    DATA field1(12).
    DATA field2(12).
    DATA field3(12).
    DATA field4(12).
    DATA cnt TYPE i.
    DATA len TYPE i.
    DATA temp TYPE i.
    DATA start TYPE i.
    DATA quote TYPE i.
    DATA rec_cnt TYPE i.
    len = strlen( str ).
    cnt = 0.
    temp = 0.
    rec_cnt = 0.
    DO.
    *  Start at the beginning
      IF start EQ 0.
        "string just ENDED start new one.
        start = 1.
        quote = 0.
        CLEAR field.
      ENDIF.
      IF str+cnt(1) EQ '"'.  "Check for qoutes
        "CHECK IF quotes is already set
        IF quote = 1.
          "Already quotes set
          "Start new field
          start = 0.
          quote = 0.
          CONCATENATE field '"' INTO field.
          IF field IS NOT INITIAL.
            rec_cnt = rec_cnt + 1.
            CONDENSE field.
            IF rec_cnt EQ 1.
              field1 = field.
            ELSEIF rec_cnt EQ 2.
              field2 = field.
            ELSEIF rec_cnt EQ 3.
              field3 = field.
            ELSEIF rec_cnt EQ 4.
              field4 = field.
            ENDIF.
          ENDIF.
    *      WRITE field.
        ELSE.
          "This is the start of quotes
          quote = 1.
        ENDIF.
      ENDIF.
      IF str+cnt(1) EQ ','. "Check end of field
        IF quote EQ 0. "This is not inside quote end of field
          start = 0.
          quote = 0.
          CONDENSE field.
    *      WRITE field.
          IF field IS NOT INITIAL.
            rec_cnt = rec_cnt + 1.
            IF rec_cnt EQ 1.
              field1 = field.
            ELSEIF rec_cnt EQ 2.
              field2 = field.
            ELSEIF rec_cnt EQ 3.
              field3 = field.
            ELSEIF rec_cnt EQ 4.
              field4 = field.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
      CONCATENATE field str+cnt(1) INTO field.
      cnt = cnt + 1.
      IF cnt GE len.
        EXIT.
      ENDIF.
    ENDDO.
    WRITE: field1, field2, field3, field4.
    ENDFORM.
    Regards,
    Wenceslaus.

  • Problems importing raw files into Lightroom 3.4

    I've just dowloaded lightroom 3.4 and now I'm having problems importing raw files into lightroom.  I havent had a problem before.  Can anyone help me?  My camera is a Nikon D7000.

    Perhaps a few more details are required. Take a look at the FAQ "How to get help quickly"

  • Have AE7; Problem importing prproj file into pc; get placeholder instead. What do I need to do to open up the video files here. They are .mov in quicktime.

    Have AE7; Problem importing prproj file into pc; get placeholder instead. What do I need to do to open up the video files here. They are .mov in quicktime.

    Please be more specific. What Premiere project? What version of Premiere? Which operating system? What CoDecs do the QT fiels use? Are all the video files in the correct folders inside the Premiere project structure? Your description sounds like you are attempting to open a Mac based project on a PC and your video files are either in the wrong location or use a Mac-specific CoDec, hence they cannot be read on a PC.
    Mylenium

Maybe you are looking for

  • Display uploaded file on JSP page

    Hi All, I want to display uploaded file in JSP. Initially I am displaying File Name after saving the file & click on edit link. i.e on JSP Page I have File Upload component & save button.With that save button I am saving my file to databse. So when I

  • How to display a picture like instruction?

    I'm want to display a pciture like working instruction before or after the UUT serial number input dialog,how to make the step ?

  • Configration File for JBoss ??

    In the section "BC4J as an EJB Session Bean" of "How Do I Deploy BC4J Applications to JBoss?" a BC4J Configuration file has been created for JBoss by modifying the IAS configuration file. But the dear fellow, who wrote the Article did not mention tha

  • Where can I find log files for users logging into network homes?

    We're running an open directory master and are using AFP on another server to host our network homes.  I was asked to find a log of users logged into their network homes on a specific date and I'm starting to wonder if that's actually a log that exis

  • Makes no sense!!

    Why would adobe have all there programs for the two major platforms of Mac and Windows, but not have the Flash Media Server for Mac??!!