i get cannot find symbol error in compile time

后端 未结 2 602
忘掉有多难
忘掉有多难 2021-01-29 07:16
import java.io.File;
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
 import java.io.*;
 import java.io.InputStream;
 class pbdemo {

     static publ         


        
相关标签:
2条回答
  • 2021-01-29 07:45

    Simple answer.

    ProcessBuilder don't have getInputStream method.

    See this: ProcessBuilder

    You can use:

    BufferedReader br=new BufferedReader(new InputStreamReader(pb.start().getInputStream()));
    
    0 讨论(0)
  • 2021-01-29 07:52

    You are trying to get an InputStream from a ProcessBuilder and that's wrong.

    ProcessBuilder.start() returns a Process object, and that's the one who has a getInputStream() method.

    Try switching that line for this one.

    BufferedReader br=new BufferedReader(new InputStreamReader(pb.start().getInputStream()));

    Or

    Process pro = pb.start();
    BufferedReader br=new BufferedReader(new InputStreamReader(pro.getInputStream()));
    
    0 讨论(0)
提交回复
热议问题