Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Personally I never tried to call method of my class with keyword <code>class</code>. If we say that your class is named <code>Foo</code>, in your Main method you should write:</p> <pre><code>mzList = Foo.filreader("precursor",mzList); </code></pre> <p>In your first Main example, this doesn't make sense:</p> <pre><code>List mzList = new LinkedList(); mzList = new ArrayList(); </code></pre> <p>It should be either LinkedList() or ArrayList(), like so:</p> <p><code>List mzList = new LinkedList();</code> or <code>List mzList = new ArrayList();</code></p> <p>Next, you are passing file name "precursor", but in the first example you are using "./precursors" (but I think you are aware of that).</p> <p>Lastly you are assigning result of your method to variable <code>mzList</code>, and pass the same list instance as parameter. If you pass list as parameter, you don't have to return it back because it the very same list as created earlier in your code (read about references). You could use something like this:</p> <pre><code>public static void filereader (String filename, LinkedList someList) { FileInputStream input = new FileInputStream(filename); DataInputStream in = new DataInputStream(input); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line; while ((line = reader.readLine()) != null) { if (line.equals("---")) { /* Do Nothing... */ } else { someList.add(line); } } in.close(); return(someList); } </code></pre> <p>and then simply (notice there is no assignment):</p> <pre><code>Foo.filreader("precursor",mzList); </code></pre> <p>As far I see, you are not making use of this input list in terms of reading data from it. Thus, you can initialize your list inside the method and return it, like so:</p> <pre><code>public static LinkedList filereader (String filename) { LinkedList someList = new LinkedList(); // notice list initialization FileInputStream input = new FileInputStream(filename); DataInputStream in = new DataInputStream(input); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line; while ((line = reader.readLine()) != null) { if (line.equals("---")) { /* Do Nothing... */ } else { someList.add(line); } } in.close(); return(someList); } </code></pre> <p>and then simply call your method and assign your results:</p> <pre><code>mzList = Foo.filreader("precursor"); </code></pre>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. 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