我是靠谱客的博主 可爱便当,最近开发中收集的这篇文章主要介绍java inputstream 传递给 py 处理,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

 

 

java  inputstream 传递给 py 处理


/**
 * @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技术扣扣群),没钱捧个人场,谢谢各位。



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

 

 

最后

以上就是可爱便当为你收集整理的java inputstream 传递给 py 处理的全部内容,希望文章能够帮你解决java inputstream 传递给 py 处理所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(49)

评论列表共有 0 条评论

立即
投稿
返回
顶部