当前位置: 首页>>代码示例>>Python>>正文


Python io.FileInputStream方法代码示例

本文整理汇总了Python中java.io.FileInputStream方法的典型用法代码示例。如果您正苦于以下问题:Python io.FileInputStream方法的具体用法?Python io.FileInputStream怎么用?Python io.FileInputStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io的用法示例。


在下文中一共展示了io.FileInputStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DoXPath

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import FileInputStream [as 别名]
def DoXPath (Filename,XPathString):
	IS = InputSource (FileInputStream (Filename))
	df = DocumentBuilderFactory.newInstance()
	df.setNamespaceAware(1)
	doc = df.newDocumentBuilder().parse(IS)
	serializer = TransformerFactory.newInstance().newTransformer()
	serializer.setOutputProperty (OutputKeys.OMIT_XML_DECLARATION, "yes")
	nl = XPathAPI.selectNodeIterator (doc,XPathString)
	n = nl.nextNode()
	while n:
		if IsTextNode (n):
			# Coalesce contiguous text nodes
			res = [n.getNodeValue()]
			nn = n.getNextSibling()
			while (nn):
				res.append (nn.getNodeValue())
				nn = n.getNextSibling()
			java.lang.System.out (string.join(res,""))
		else:
			serializer.transform (DOMSource(n), StreamResult (OutputStreamWriter (java.lang.System.out)))
		java.lang.System.out.println()
		n = nl.nextNode() 
开发者ID:ActiveState,项目名称:code,代码行数:24,代码来源:recipe-274905.py

示例2: input_graph

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import FileInputStream [as 别名]
def input_graph(self, input_filename):
        GraphSONReader.inputGraph(self.graph, FileInputStream(input_filename)) 
开发者ID:pokitdok,项目名称:gremlin-python,代码行数:4,代码来源:gremthon.py

示例3: _test_blob

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import FileInputStream [as 别名]
def _test_blob(self, obj=0):
        assert self.has_table("blobtable"), "no blob table"
        tabname, sql = self.table("blobtable")
        fn = tempfile.mktemp()
        fp = None

        c = self.cursor()
        try:

            hello = ("hello",) * 1024

            c.execute(sql)
            self.db.commit()

            from java.io import FileOutputStream, FileInputStream, ObjectOutputStream, ObjectInputStream, ByteArrayInputStream

            fp = FileOutputStream(fn)
            oos = ObjectOutputStream(fp)
            oos.writeObject(hello)
            fp.close()

            fp = FileInputStream(fn)
            blob = ObjectInputStream(fp)
            value = blob.readObject()
            fp.close()
            assert hello == value, "unable to serialize properly"

            if obj == 1:
                fp = open(fn, "rb")
            else:
                fp = FileInputStream(fn)

            c.execute("insert into %s (a, b) values (?, ?)" % (tabname), [(0, fp)], {1:zxJDBC.BLOB})
            self.db.commit()

            c.execute("select * from %s" % (tabname))
            f = c.fetchall()
            bytes = f[0][1]
            blob = ObjectInputStream(ByteArrayInputStream(bytes)).readObject()

            assert hello == blob, "blobs are not equal"

        finally:
            c.execute("drop table %s" % (tabname))
            c.close()
            self.db.commit()
            if os.path.exists(fn):
                if fp:
                    fp.close()
                os.remove(fn) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:52,代码来源:zxtest.py


注:本文中的java.io.FileInputStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。