MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / executeCmd

Method executeCmd

src/main/java/core/packetproxy/common/Utils.java:123–144  ·  view source on GitHub ↗
(String... command)

Source from the content-addressed store, hash-verified

121 }
122
123 public static byte[] executeCmd(String... command) throws Exception {
124 Process p = Runtime.getRuntime().exec(toCmdArray(command));
125 InputStream in = p.getInputStream();
126 ByteArrayOutputStream bout = new ByteArrayOutputStream();
127 byte[] buffer = new byte[4096];
128 int len = 0;
129 while ((len = in.read(buffer, 0, 4096)) > 0) {
130
131 bout.write(buffer, 0, len);
132 }
133 InputStream err = p.getErrorStream();
134 ByteArrayOutputStream berr = new ByteArrayOutputStream();
135 while ((len = err.read(buffer, 0, 4096)) > 0) {
136
137 berr.write(buffer, 0, len);
138 }
139 if (berr.size() > 0) {
140
141 err(berr.toString());
142 }
143 return bout.toByteArray();
144 }
145
146 /**
147 * EXEを実行する。MACの場合はmonoで実行する

Callers

nothing calls this directly

Calls 8

toCmdArrayMethod · 0.95
errMethod · 0.80
getInputStreamMethod · 0.65
writeMethod · 0.65
readMethod · 0.45
sizeMethod · 0.45
toStringMethod · 0.45
toByteArrayMethod · 0.45

Tested by

no test coverage detected