MCPcopy Create free account
hub / github.com/OpenVPN/openvpn3 / readStream

Method readStream

javacli/Main.java:33–51  ·  view source on GitHub ↗
(InputStream stream)

Source from the content-addressed store, hash-verified

31 }
32
33 private static String readStream(InputStream stream) throws IOException {
34 // No real need to close the BufferedReader/InputStreamReader
35 // as they're only wrapping the stream
36 try {
37 Reader reader = new BufferedReader(new InputStreamReader(stream));
38 StringBuilder builder = new StringBuilder();
39 char[] buffer = new char[4096];
40 int read;
41 while ((read = reader.read(buffer, 0, buffer.length)) > 0) {
42 builder.append(buffer, 0, read);
43 }
44 return builder.toString();
45 } finally {
46 // Potential issue here: if this throws an IOException,
47 // it will mask any others. Normally I'd use a utility
48 // method which would log exceptions and swallow them
49 stream.close();
50 }
51 }
52
53 public static void main(String[] args) throws IOException, Client.ConfigError, Client.CredsUnspecifiedError {
54 if (args.length >= 1)

Callers 1

readFileMethod · 0.95

Calls 3

readMethod · 0.45
appendMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected