Input:
politechnika,autonomia,wojtas,gra,polistanczysk
jareksamoraj,cc,chingismog,uu,tttttttt
Output:
politechnika,autonomia,polistanczysk,jareksamoraj,chingismog,tttttttt
package com.codegym.task.task19.task1925;
/*
Long words
*/
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
public class Solution {
public static void main(String[] args) throws IOException {
String fileName1 = args[0];
String fileName2 = args[1];
ArrayList<String> list = new ArrayList<>();
ArrayList<String> good = new ArrayList<>();
FileReader fr = new FileReader(fileName1);
BufferedReader br = new BufferedReader(fr);
FileWriter fw = new FileWriter(fileName2);
while (br.ready()) {
String a = br.readLine();
String[] str = a.split(",");
for (String x :
str) {
list.add(x);
}
}
fr.close();
br.close();
// StringBuilder sb = new StringBuilder();
for (String x :
list) {
if (x.length() > 6) {
// sb.append(x + ",");
good.add(x + ",");
}
}
// sb.setLength(sb.length() - 1);
// String k = sb.toString();
String a = good.get(good.size() - 1);
good.remove(good.size() - 1);
String b = a.substring(0, a.indexOf(","));
good.add(b);
for (String x:
good) {
fw.write(x);
}
// fw.write(k);
fw.close();
}
}