I'm feeling there's some insanely dumb and obvious here, but i cant see it
package com.codegym.task.task19.task1925;
/*The main method's first parameter is file1 and the second is file2.
file1 contains words separated by spaces.
Write to file2 a comma-separated list of words longer than 6 characters.
file2 should not end with a comma.
Close the streams.
Example output to file2:
lengthy,shortened,abbreviation*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(args[0]));
String[] s = reader.readLine().trim().split(" ");
reader.close();
StringBuilder res = new StringBuilder();
for (String word : s) {
if (word.length() > 6) {
res.append(word).append(',');
}
}
FileWriter writer = new FileWriter(args[1]);
writer.write(res.substring(0, res.length() - 1));
writer.close();
}
}