X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FHtmlFile.java;fp=src%2Fjalview%2Fio%2FHtmlFile.java;h=a4e9bf4bb15b024746f52691ca8d39086f73e811;hb=c9df5bd6e95c23c9b560c0a59003d1f4043f8055;hp=73aa5d2e6120a42ce14529f8b069d170bd7f799d;hpb=f59ae49cdd2bb8f6721424ea6ce167e8245e7d15;p=jalview.git diff --git a/src/jalview/io/HtmlFile.java b/src/jalview/io/HtmlFile.java index 73aa5d2..a4e9bf4 100644 --- a/src/jalview/io/HtmlFile.java +++ b/src/jalview/io/HtmlFile.java @@ -22,6 +22,7 @@ package jalview.io; import java.io.IOException; +import java.io.StringReader; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; @@ -66,18 +67,24 @@ public class HtmlFile extends AlignFile implements ComplexAlignFile { try { - StringBuilder htmlData = new StringBuilder(); - String currentLine; - while ((currentLine = nextLine()) != null) - { - htmlData.append(currentLine); + Element content = null; + Document doc = null; + try { + StringBuilder htmlData = new StringBuilder(); + String currentLine; + while ((currentLine = nextLine()) != null) + { + htmlData.append(currentLine); + } + + doc = Jsoup.parse(htmlData.toString()); + } catch (OutOfMemoryError oom) { + errormessage = "Not enough memory to process HTML document"; + throw new IOException(errormessage); } - - Document doc = Jsoup.parse(htmlData.toString()); - Element content = doc.getElementById("seqData"); - String alignmentJsonString = content.val(); - - JSONFile jsonFile = new JSONFile().parse(alignmentJsonString); + content = doc.getElementById("seqData"); + + JSONFile jsonFile = new JSONFile().parse(new StringReader(content.val())); this.seqs = jsonFile.getSeqs(); this.seqGroups = jsonFile.getSeqGroups(); this.annotations = jsonFile.getAnnotations(); @@ -87,7 +94,8 @@ public class HtmlFile extends AlignFile implements ComplexAlignFile this.columnSelection = jsonFile.getColumnSelection(); } catch (Exception e) { - e.printStackTrace(); + errormessage = "Failed to extract data from HTML document."; + throw new IOException("Unexpected exception whilst extracting JSon from HTML.",e); } }