jaba
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class test {
public static void main(String args[]) throws Exception {
Process pb = new ProcessBuilder().command("php", "php.php", "123").start();
BufferedReader in = new BufferedReader(new InputStreamReader(pb.getInputStream()));
PrintWriter out = new PrintWriter(pb.getOutputStream());
Thread.sleep(1000);
out.println("321\r\n\r\n");
System.out.println(in.readLine());
System.out.println(in.readLine());
System.out.println(in.readLine());
System.out.println(in.readLine());
System.out.println(in.readLine());
}
}
----------------
pha
<?
$f = fopen("php://stdin","r+");
$read = fread($f,4096);
$read = str_replace("\r\n","",$read);
fclose($f);
echo "3331\n";
echo $argv[1]."\n";
echo "3332\n";
echo $read."\n";
echo "3333\n";
Вывод:
null
null
null
null
null
null
Ожидаемый вывод:
3331
123
3332
321
3333
Почему программа выводит неправильные значения?