package org.cacert.gigi.testUtils;
+import java.io.ByteArrayOutputStream;
import java.io.CharArrayWriter;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.HttpURLConnection;
while ((len = in.read(buffer)) > 0) {
caw.write(buffer, 0, len);
}
+ in.close();
return new String(caw.toCharArray());
} catch (IOException e) {
throw new Error(e);
}
}
+
+ public static byte[] readURL(InputStream in) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ byte[] buffer = new byte[1024];
+ int len = 0;
+ try {
+ while ((len = in.read(buffer)) > 0) {
+ baos.write(buffer, 0, len);
+ }
+ in.close();
+ return baos.toByteArray();
+ } catch (IOException e) {
+ throw new Error(e);
+ }
+ }
}