java inputstream 传递给 py 处理_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > java inputstream 传递给 py 处理

java inputstream 传递给 py 处理

 2017/5/25 5:34:39  knight_black_bob  程序员俱乐部  我要评论(0)
  • 摘要:javainputstream传递给py处理/***@authorbaoyouE-mail:curiousby@163.com*@version2016年8月1日下午1:05:36*<pre><dependency><groupId>jython</groupId><artifactId>jython</artifactId><version>2.1</version><
  • 标签:Java

?

?

java ?inputstream 传递给 py 处理


class="java">/**
 * @author baoyou E-mail:curiousby@163.com
 * @version 2016年8月1日 下午1:05:36
 *<pre>
 <dependency>
    <groupId>jython</groupId>
    <artifactId>jython</artifactId>
    <version>2.1</version>
 </dependency>
 *</pre>
 * desc: ...
 */
public class PythonByJavaInputStream {

    public static void main(String[] args) throws FileNotFoundException {

        PythonInterpreter interpreter = new PythonInterpreter();
        interpreter.execfile("I:\\cache\\ea-ws\\DemoJava\\conf\\pystream.py");
        PyFunction func = (PyFunction) interpreter.get("processFile", PyFunction.class);
        File file = new File("I:\\cache\\ea-ws\\DemoJava\\conf\\1.txt");
        InputStream in = new FileInputStream(file);
        func.__call__(new PyFile(in));
    }

}

??


?

?

#!/usr/bin/python3
# -*- coding: UTF-8 -*- 
'''
Created on 2017年5月24日

@author: hadoop
'''
def process(filepath):
     file = open(filepath, 'r')
     processFile(file)
      
def processFile(file):
     print "===================="
     lines= file.readlines()
     for line in lines:
        print line
     file.close()
     print "===================="

?

?

?

?

?

?

?

?

?

?

?

?

?

?

捐助开发者

在兴趣的驱动下,写一个免费的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(支持支付宝和微信捐助,加入it技术扣扣群),没钱捧个人场,谢谢各位。



?
?
?谢谢您的赞助,我会做的更好!

?

?

  • 大小: 80.1 KB
  • 大小: 12 KB
  • 查看图片附件
发表评论
用户名: 匿名