How can i make constructor that can handle IOException
this is the class with constructor
public class RootProcess {
Process process;
public RootProcess() throws IOException {
}
public RootProcess(Process process){
this.process = process;
}
public Process getProcess() {
return process;
}
public void setProcess(Process process) {
this.process = process;
}
}
And this is how i declare it
RootProcess process = new RootProcess(Runtime.getRuntime().exec("su"));
but i get this error in eclipse
Default constructor cannot handle exception type IOException thrown by implicit super constructor. Must define an explicit constructor
if you running this from a method either declare the exception in method signature or handle it using try/catch block.
Declaring the exception:
Handle the Exception: