File tree Expand file tree Collapse file tree 3 files changed +16
-9
lines changed
src/main/java/com/excellence/exec Expand file tree Collapse file tree 3 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -29,8 +29,8 @@ dependencies {
2929 testImplementation ' junit:junit:4.12'
3030 androidTestImplementation ' com.android.support.test:runner:1.0.2'
3131 androidTestImplementation ' com.android.support.test.espresso:espresso-core:3.0.2'
32- implementation ' io.reactivex.rxjava2:rxjava:2.2.0 '
33- implementation ' io.reactivex.rxjava2:rxandroid:2.0.2 '
32+ implementation ' io.reactivex.rxjava2:rxjava:2.2.3 '
33+ implementation ' io.reactivex.rxjava2:rxandroid:2.1.0 '
3434}
3535
3636/* ********************上传jCenter依赖*********************/
Original file line number Diff line number Diff line change 1313import io .reactivex .functions .Consumer ;
1414import io .reactivex .schedulers .Schedulers ;
1515
16+ import static com .excellence .exec .ProcessUtils .closeStream ;
17+
1618/**
1719 * <pre>
1820 * author : VeiZhang
@@ -235,14 +237,20 @@ public void accept(Long aLong) throws Exception {
235237 BufferedReader stdin = new BufferedReader (new InputStreamReader (mProcess .getInputStream ()));
236238 StringBuilder result = new StringBuilder ();
237239 String line = null ;
238- while (mStatus == STATUS_RUNNING && (line = stdin .readLine ()) != null ) {
239- if (mStatus == STATUS_RUNNING ) {
240- restartTimer ();
241- mIListener .onProgress (line );
242- result .append (line );
240+ try {
241+ while (mStatus == STATUS_RUNNING && (line = stdin .readLine ()) != null ) {
242+ if (mStatus == STATUS_RUNNING ) {
243+ restartTimer ();
244+ mIListener .onProgress (line );
245+ result .append (line );
246+ }
243247 }
248+ } catch (Exception e ) {
249+ e .printStackTrace ();
250+ } finally {
251+ closeStream (mProcess );
252+ stdin .close ();
244253 }
245- stdin .close ();
246254 resetTimer ();
247255 if (mStatus == STATUS_RUNNING ) {
248256 mIListener .onSuccess (result .toString ());
Original file line number Diff line number Diff line change @@ -69,7 +69,6 @@ public static void closeStream(@NonNull Process process) {
6969 }
7070
7171 public static void destroyProcess (@ NonNull Process process ) {
72- closeStream (process );
7372 killProcess (process );
7473 }
7574}
You can’t perform that action at this time.
0 commit comments