JetBrains Academy: Output streams - Kamil-Jankowski/Learning-JAVA GitHub Wiki

JetBrains Academy: Output streams

Convert to byte array:

Implement the convert method that converts String[] to char[].

import java.io.*;

class Converter {
    public static char[] convert(String[] words) throws IOException {
        CharArrayWriter writer = new CharArrayWriter();

        for (String word : words) {
            for (int i = 0; i < word.length(); i++) {
                writer.append(word.charAt(i));
            }
        }

        return writer.toCharArray();
    }
}