本文整理汇总了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()
示例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))
示例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)