dongzi4030 2013-10-06 22:32
浏览 43
已采纳

用PHP获取Java Println输出

I'm trying to get the output from a java application that would use the below code to output values

System.out.println(object.getNumber(3));
System.out.println(object.getNumber(4));

I'm using exec("somejavapath javaName", $output) and print_r($output) to get that output array to print. I know it will get the values but I wanted to get into a certain format So instead of

Array
(
[0] => 34
)

I want something like this

Array
(
[0] => 3
[1] => 4
)

Does anyone know what I could do to get this format?

Thanks

  • 写回答

2条回答 默认 最新

  • douzhu1188 2013-10-07 03:39
    关注

    If you are not expecting comas in the output from java application , include a coma between the two values :

    System.out.println(object.getNumber(3));
    System.out.println(",");    // Print a coma in between
    System.out.println(object.getNumber(4));
    

    Then

    $values_array = explode( ',', $output );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥15 关于超局变量获取查询的问题
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能