Skip to content

Instantly share code, notes, and snippets.

@alebaffa
Created October 9, 2016 20:39
Show Gist options
  • Save alebaffa/b4e9323e3b692cb6de63efa1c08fa41d to your computer and use it in GitHub Desktop.
Save alebaffa/b4e9323e3b692cb6de63efa1c08fa41d to your computer and use it in GitHub Desktop.
public class HtmlTextConverter {
private ReaderFactory readerFactory;
public HtmlTextConverter(String fullFilenameWithPath) {
this(new FileReaderFactory(fullFilenameWithPath));
}
public HtmlTextConverter(ReaderFactory readerFactory) {
this.readerFactory = readerFactory;
}
public String convertToHtml() throws IOException {
Formatter htmlFormatter = getHtmlFormatter();
htmlFormatter.convertToHtml();
return htmlFormatter.getHtml();
}
private Formatter getHtmlFormatter() throws IOException {
return new HtmlFormatter(readerFactory.createReader());
}
public String getFilename() {
return readerFactory.getItemName();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment