Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Create a new Class that will hold the data of a row. In the easiest case you could create a class like this:</p> <pre><code>class MyClass { public String column1; public String column2; public ArrayList&lt;String&gt; aliases = new ArrayList&lt;String&gt;(); public void addAliases(String[] a){ for(int i=2;i&lt;a.length;i++){ aliases.add(a[i]); } } } </code></pre> <p>Then change your ArrayList like so: <code>ArrayList&lt;MyClass&gt; clubsArr = new ArrayList&lt;MyClass&gt;();</code></p> <p>and your reading part like so:</p> <pre><code>while ((line = clubBR.readLine()) != null) { MyClass club = new MyClass; String[] value = line.split(",", 3); club.column1 = value[0]; club.column2 = value[1]; // etc... clubsArr.add(club); } MyClass[] clubs = clubsArr.toArray(); </code></pre> <p>That way you will later be able to get a value from one of the objects by using its attributename (in this case for example <code>.column2</code>) instead of some index you would have to keep in mind.</p> <p>Note that you can call the attributes in the class to your liking (e.g. <code>clubname</code> instead of <code>column1</code>)</p> <p><strong>EDIT (to help with OPs edit)</strong> To check, if the file exists, replace the line <code>BufferedReader clubBR = new BufferedReader(new FileReader(new File("nrlclubs.txt")));</code></p> <p>with</p> <pre><code>File file = new File("nrlclubs.txt"); if(!file.exists()){ System.exit(1); // no use to go any further if we have no input } BufferedReader clubBR = new BufferedReader(new FileReader(file)); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload