@Override public String getContent() throws FileNotFound, CannotReadFile { try { URLConnection connection = getInputURL().openConnection(); Reader input = charsetName != null ? new InputStreamReader(connection.getInputStream(), charsetName) : new InputStreamReader(connection.getInputStream()); String content = IOUtils.toString(input).replace("\r\n", "\n"); setLastModified(connection.getLastModified()); input.close(); return content; } catch (FileNotFoundException ex) { throw new FileNotFound(); } catch (IOException ex) { throw new CannotReadFile(); } }
@Override public byte[] getBytes() throws FileNotFound, CannotReadFile { try { URLConnection connection = getInputURL().openConnection(); Reader input = new InputStreamReader(connection.getInputStream()); setLastModified(connection.getLastModified()); byte[] content = IOUtils.toByteArray(input); input.close(); return content; } catch (FileNotFoundException ex) { throw new FileNotFound(); } catch (IOException ex) { throw new CannotReadFile(); } }