import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import org.apache.commons.lang3.StringUtils; public class Main { public static void main(String[] args) { ArrayList<String> data = new ArrayList<>(); data.add("Java"); data.add("Library"); data.add("Example"); try (FileWriter writer = new FileWriter("output.txt")) { for (String item : data) { writer.write(StringUtils.reverse(item) + "\n"); } System.out.println("Data written to file."); } catch (IOException e) { e.printStackTrace(); } } }