public String readFile(DocumentName documentName) { try { PDocument pdocument = getPDocument(documentName, (long) 0); InputSource source = pdocument.read(); Reader reader = source.getCharacterStream(); if (reader != null) { return read(reader); } else { InputStream inputStream = source.getByteStream(); return stream(inputStream); } } catch (MDSIOException e) { throw new IllegalArgumentException("Could not connect to MDS, check login data", e); } catch (IOException e) { throw new IllegalArgumentException("Could not read ", e); } }