ArrayList<Int> Collections.Sort and LineNumberReader Help How to

Posted by user1819551 on Stack Overflow See other posts from Stack Overflow or by user1819551
Published on 2012-11-20T16:40:30Z Indexed on 2012/11/20 17:00 UTC
Read the original article Hit count: 277

Filed under:

I have a issue i can't get it to work now let going to the point a explain in the code thanks.

This is my class: what I want to do is insert the Integers sort the list and buffer writer in a column with out coma. Now I getting this: [1110018, 1110032, 1110056, 1110059, 1110063, 1110085, 1110096, 1110123, 1110125, 1110185, 1110456, 1110459]

I want like this:

111xxxxx  
111xxxx  
xxxx.......

I can't do it in single array, have to be in ArrayList.
This is my collecting:

list.addNumbers(numbers); 
list.display();

This is my writer: Is buffered

coma.write("\n"+list.display());
coma.flush();<br/>

Here is my class:

public class IdCount {<br/>
  private ArrayList<Integer> properNumber = new ArrayList<>();

  public void addNumbers(Integer numbers) {
    properNumber.add(numbers);
    Collections.sort(properNumber);
  }

  public String display() {
    //(I try .toString() Not work)
    return properNumber.toString();
  }

My second issue is LineNumberReader: This is my collecting and my writing:

try {
  Reader input = new BufferedReader( new FileReader(inputFile));
  try (Scanner in = new Scanner(input)) {
    while (in.hasNext()) {
      //(More Code)
      asp = new LineNumberReader(input);
      int rom = 0;

      while (asp.readLine()!=null){
        rom++;
      }
    System.out.println(rom);
    coma.write(rom);

This one will not write anything an my System Print give me only 12 0 in column.

© Stack Overflow or respective owner

Related posts about java