package org.tizen.cli.exec.pack;
import java.io.BufferedReader;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.MessageFormat;
import java.util.ArrayList;
import org.tizen.common.core.command.CommandCancelException;
import org.tizen.common.core.command.Prompter;
import org.tizen.common.util.FileUtil;
+import org.tizen.common.util.IOUtil;
import org.tizen.common.util.OSChecker;
import org.tizen.common.util.StringUtil;
Process cmdP = Runtime.getRuntime().exec(cmdList.toArray(new String[cmdList.size()]));
String line;
- BufferedReader outReader = new BufferedReader(new InputStreamReader(cmdP.getInputStream()));
- while((line = outReader.readLine()) != null ) {
- prompter.notify(line);
- }
- BufferedReader errReader = new BufferedReader(new InputStreamReader(cmdP.getErrorStream()));
- while((line = errReader.readLine()) != null) {
- prompter.error(line);
+ InputStream is = null;
+ InputStream eis = null;
+ try {
+ is = cmdP.getInputStream();
+ BufferedReader outReader = new BufferedReader(new InputStreamReader(is));
+ while((line = outReader.readLine()) != null ) {
+ prompter.notify(line);
+ }
+
+ eis = cmdP.getErrorStream();
+ BufferedReader errReader = new BufferedReader(new InputStreamReader(eis));
+ while((line = errReader.readLine()) != null) {
+ prompter.error(line);
+ }
+ }
+ finally {
+ IOUtil.tryClose(is, eis);
}
}