comparison src/main/java/de/intevation/artifacts/httpclient/http/response/StringResponseHandler.java @ 0:a1db30b33f43

Moved the experimental branch 'work-on-gwt' of the console-client to an own module 'http-client' and removed the console-client. http-client/trunk@1323 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 17 Feb 2011 10:31:40 +0000
parents
children 0359c4f3b4a1
comparison
equal deleted inserted replaced
-1:000000000000 0:a1db30b33f43
1 /*
2 * Copyright (c) 2010 by Intevation GmbH
3 *
4 * This program is free software under the LGPL (>=v2.1)
5 * Read the file LGPL.txt coming with the software for details
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
7 */
8 package de.intevation.artifacts.httpclient.http.response;
9
10 import java.io.ByteArrayOutputStream;
11 import java.io.InputStream;
12 import java.io.IOException;
13 import java.io.OutputStream;
14
15 import org.restlet.Response;
16 import org.restlet.representation.Representation;
17
18
19 /**
20 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
21 */
22 public class StringResponseHandler extends StreamResponseHandler {
23
24 public StringResponseHandler() {
25 }
26
27 public Object handle(Response response) throws IOException {
28 InputStream in = (InputStream) super.handle(response);
29 OutputStream out = new ByteArrayOutputStream();
30
31 byte[] b = new byte[4096];
32 int i = -1;
33 while ((i = in.read(b)) > 0) {
34 out.write(b, 0, i);
35 }
36 out.close();
37
38 return out.toString();
39 }
40 }
41 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org