src/qualification/Translator.java
public static void writeOutput(Output output, File outFile) throws IOException {
        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile)))) {
            writer.write("" + output.getLibraryCount());
            writer.newLine();
            if (output.getLibraries() != null) {
                for (Library library : output.getLibraries()) {
                    List<Book> scannedBooks = library.getBooks().stream().filter(book -> book.getScanned().equals(Boolean.TRUE)).collect(Collectors.toList());
                    if (!scannedBooks.isEmpty()) {

                        writer.write(library.getId() + " " + scannedBooks.size());
                        writer.newLine();

                        StringBuilder scannedBookLine = new StringBuilder();
                        for (Book scannedBook :
                                scannedBooks) {
                            scannedBookLine.append(" ").append(scannedBook.getId());
                        }
                        writer.write("" + scannedBookLine.toString().trim() + "");
                        writer.newLine();
                    }
                }
                writer.write(" ");
            }
        }
    }
// Write Output File from Output Bean
Write Output File from Output Bean
Write Output File from Output Bean
public static void writeOutput(Output output, File outFile) throws IOException {
        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile)))) {
            writer.write("" + output.getLibraryCount());
            writer.newLine();
            if (output.getLibraries() != null) {
                for (Library library : output.getLibraries()) {
                    List<Book> scannedBooks = library.getBooks().stream().filter(book -> book.getScanned().equals(Boolean.TRUE)).collect(Collectors.toList());
                    if (!scannedBooks.isEmpty()) {
                        writer.write(library.getId() + " " + scannedBooks.size());
                        writer.newLine();
                        StringBuilder scannedBookLine = new StringBuilder();
                        for (Book scannedBook :
                                scannedBooks) {
                            scannedBookLine.append(" ").append(scannedBook.getId());
                        }
                        writer.write("" + scannedBookLine.toString().trim() + "");
                        writer.newLine();
                    }
                }
                writer.write(" ");
            }
        }
    }
public static void writeOutput ( Output output , File outFile ) throws IOException { try ( BufferedWriter writer = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( outFile ) ) ) ) { writer . write ( "" + output . getLibraryCount ( ) ) ; writer . newLine ( ) ; if ( output . getLibraries ( ) != null ) { for ( Library library : output . getLibraries ( ) ) { List < Book > scannedBooks = library . getBooks ( ) . stream ( ) . filter ( book -> book . getScanned ( ) . equals ( Boolean . TRUE ) ) . collect ( Collectors . toList ( ) ) ; if ( ! scannedBooks . isEmpty ( ) ) { writer . write ( library . getId ( ) + " " + scannedBooks . size ( ) ) ; writer . newLine ( ) ; StringBuilder scannedBookLine = new StringBuilder ( ) ; for ( Book scannedBook : scannedBooks ) { scannedBookLine . append ( " " ) . append ( scannedBook . getId ( ) ) ; } writer . write ( "" + scannedBookLine . toString ( ) . trim ( ) + "" ) ; writer . newLine ( ) ; } } writer . write ( " " ) ; } } }
Write Output File from Output Bean
Write Output File from Output Bean