OWLAPIOwl2Obo owl2obo = new OWLAPIOwl2Obo(
OWLManager.createOWLOntologyManager());
OBODoc obodoc = owl2obo.convert(ontology);
checkOBODoc(obodoc);
// ROUNDTRIP AND TEST AGAIN
OBOFormatWriter w = new OBOFormatWriter();
ByteArrayOutputStream os = new ByteArrayOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8");
BufferedWriter bw = new BufferedWriter(osw);
w.setCheckStructure(true);
w.write(obodoc, bw);
bw.close();
OBOFormatParser p = new OBOFormatParser();
obodoc = p.parse(new BufferedReader(new InputStreamReader(
new ByteArrayInputStream(os.toByteArray()))));
checkOBODoc(obodoc);