Hi everyone 

 

I am attempting to read a .csv file from a directory, however I am not
sure what I am doing wrong here. I am using a BufferedReader to read the
file. Then I am looping through using the readLine() method and
assigning each line to an ArrayList, well I thought it was as simple as
that :-( 

 

When my .tml file loads it displays the grid table incorrectly, so I am
assuming that my object (arrayList) is wrong. 

 

Here is my EventLink method which reads the file and assigns it to an
arrayList. 

 

....

@Property

private List newStores;

 

....

 

Object onProcess() {

      File file = new File(getAbsolutePath(this.url));

      this.newStores = new ArrayList();

      

      if (file.canRead()) {

          try {

            // Construct the BufferedReader object

            this.bufferedReader = new BufferedReader(new
FileReader(getAbsolutePath(this.url)));

            String line = null;

 

            while ((line = bufferedReader.readLine()) != null) {

                this.newStores.add(line);

            }// end of while

          } catch (IOException ex) {

            ex.printStackTrace();

          } finally {

            // Close the BufferedReader

            try {

                if (this.bufferedReader != null)

                  this.bufferedReader.close();

            } catch (IOException ex) {

                ex.printStackTrace();

            }

          }

      }

 

      this.result = !this.result;

      return this.zone;

    }

 

  public String getAbsolutePath(String context) {

      String url = globals.getServletContext().getRealPath(context);

      return url;

    }

 

 

My grid component displays a header called empty and one column with 8
rows showing false. Like the example below. 

 

Empty

false

false

false

false

false

false

 

 

 

 

...and here is the format of my .csv file in excel would look like: 

 

StoreName

Store code

Card acceptor id

Row 1

1234

123

Row 2

1235

234

Row 3

1234

432

Row 4 

3453

222

Row 5

234

234

Row 6

4455

3445

Row 7

3445

444

Row 8 

4558

222

 

 

Thanking you in advance ! 

Regards Eldred 

Reply via email to