Hello, good night, everyone
After spending some time researching and finding nothing about the topic, or maybe you just do not know how to look I come to ask a question about an exercise I have in class.
The exercise says that I must generate a child process that receives input characters from the parent class, capitalizes them, and the parent class has to output the result on the screen.
Here I post as I have the child process (it is exported as runnable jar).
public class Mayusculas {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
InputStreamReader entrada = new InputStreamReader(System.in);
BufferedReader teclado = new BufferedReader (entrada);
String cadena = teclado.readLine();
System.out.println(cadena.toUpperCase());
}}
Well, this class I have as jar, and I pass it as arguments to this:
public class MayusculasPadre {
public static void main(String[] args) throws IOException {
Process process = new ProcessBuilder(args).start();
InputStream out = process.getInputStream();
InputStreamReader isr = new InputStreamReader(out);
BufferedReader br = new BufferedReader(isr);
String linea;
linea=br.readLine();
System.out.println("Linea:"+linea);
br.close();
}}
The fault is that the entry to the process is not weighed.
Would someone know how to do it?
Thanks