(String... command)
| 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で実行する |
nothing calls this directly
no test coverage detected