Count characters of a text file This program counts the number of the occurence of each character that is used in a file. 

I tried to use everything that Java offers to me properly. If you have tips which library functions would have been better, how to make the code more readable, than let me know. If you have a tip how to improve the performance I would be very thankful, also if the readability would decrease than.

import java.util.Map;
import java.util.HashMap;
import java.io.File;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        if (args[0].contains("help")) {
            System.out.println("usage: java Main filename.txt");
        }

        Map&lt;Character, Integer&gt; map = new HashMap&lt;&gt;();
        char[] chars = fileToCharList(args[0]);
        for (int i = 0; i &lt; chars.length; i++) {
            if (map.containsKey(chars[i])) {
                Integer number = map.get(chars[i]);
                map.put(chars[i], ++number);
            } else {
                map.put(chars[i], 1);
            }
        }

        for (Map.Entry&lt;Character, Integer&gt; entry : map.entrySet()) {
            System.out.println(entry.getKey() + ": " + entry.
              getValue());
        }
    }

    private static char[] fileToCharList(String fileName) {
        File file = new File(fileName);
        StringBuilder sb = new StringBuilder();
        try (BufferedReader br = new BufferedReader(new FileReader(
          file))) {
            String line;
            while ((line = br.readLine()) != null) {
                sb.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return sb.toString().toCharArray();
    }
}
A couple of things I noticed:

Using a TreeMap, instead of converting a StringBuilder to a char[] and creating the map, is much more efficient.

You don't test for an empty argument list.

Telling the user they have to use .txt in the filename is inaccurate as your code doesn't test for that.

When you're printing multiple values on one line, it is more efficient and easier to maintain to use printf, rather than concatenating strings;

Something like this will work:

public static void main(String[] args) throws IOException {
    if (args.length &lt; 1 || args[0].equals("help")) {
        System.out.println("usage: java Main filename");
        return;
    }
    fileToChars(args[0])
            .forEach((k, v) -&gt; System.out.printf("%1$s: %2$d\n", k, v));
}

private static TreeMap&lt;Character, Integer&gt; fileToChars(String fileName) throws IOException {
    final char EOF = (char) -1;
    File file = new File(fileName);
    TreeMap&lt;Character, Integer&gt; builder = new TreeMap&lt;&gt;();
    try (FileReader reader = new FileReader(file)) {
        Character input;
        while ((input = (char) reader.read()) != EOF) {
            Integer count = builder.getOrDefault(input, 0);
            builder.put(input, ++count);
        }
    } catch (IOException e) {
        throw new IOException("Problem reading file");
    }
    return builder;
}


This gives a sorted output of the mapped Characters.  If an 'as is' output is wanted, change the TreeMap to a HashMap.