List of usage examples for javax.servlet ServletOutputStream println
public void println() throws IOException
From source file:org.gss_project.gss.server.rest.Webdav.java
/** * Copy the contents of the specified input stream to the specified output * stream, and ensure that both streams are closed before returning (even in * the face of an exception).//from www. jav a2 s .co m * * @param file * @param ostream The output stream to write to * @param ranges Enumeration of the ranges the client wanted to retrieve * @param contentType Content type of the resource * @param req the HTTP request * @param oldBody the old version of the file, if requested * @exception IOException if an input/output error occurs * @throws RpcException * @throws InsufficientPermissionsException * @throws ObjectNotFoundException */ protected void copy(FileHeader file, ServletOutputStream ostream, Iterator ranges, String contentType, HttpServletRequest req, FileBody oldBody) throws IOException, ObjectNotFoundException, InsufficientPermissionsException, RpcException { IOException exception = null; User user = getUser(req); while (exception == null && ranges.hasNext()) { InputStream resourceInputStream = oldBody == null ? getService().getFileContents(user.getId(), file.getId()) : getService().getFileContents(user.getId(), file.getId(), oldBody.getId()); InputStream istream = new BufferedInputStream(resourceInputStream, input); Range currentRange = (Range) ranges.next(); // Writing MIME header. ostream.println(); ostream.println("--" + mimeSeparation); if (contentType != null) ostream.println("Content-Type: " + contentType); ostream.println("Content-Range: bytes " + currentRange.start + "-" + currentRange.end + "/" + currentRange.length); ostream.println(); // Printing content exception = copyRange(istream, ostream, currentRange.start, currentRange.end); istream.close(); } ostream.println(); ostream.print("--" + mimeSeparation + "--"); // Rethrow any exception that has occurred if (exception != null) throw exception; }