Python java.io.FileInputStream() Examples
The following are 5
code examples of java.io.FileInputStream().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
java.io
, or try the search function
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: recipe-274905.py From code with MIT License | 6 votes |
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()
Example #2
Source File: gremthon.py From gremlin-python with MIT License | 5 votes |
def input_graph(self, input_filename): GraphSONReader.inputGraph(self.graph, FileInputStream(input_filename))
Example #3
Source File: zxtest.py From medicare-demo with Apache License 2.0 | 4 votes |
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)
Example #4
Source File: zxtest.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 4 votes |
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)
Example #5
Source File: zxtest.py From CTFCrackTools with GNU General Public License v3.0 | 4 votes |
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)