/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package p2; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; import java.util.List; /** * * @author Melnikov */ public class ContentsGenerator { static String generateContents(List objects){ StringBuilder sb=new StringBuilder(); sb.append(""); for(Describable d: objects){ sb.append(""); } sb.append("
").append(d.title()).append(""); sb.append(d.description()); sb.append("
"); return sb.toString(); } static void saveContents(String filename, List objects){ try{ Files.write(Paths.get(filename), generateContents(objects).getBytes()); } catch(Exception ex){ ex.printStackTrace(); } } }