Skip to content

Commit d036b45

Browse files
committed
Cleanup
1 parent 6a2fbb9 commit d036b45

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

javaobj.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,6 @@ def __iter__(self):
368368
def __len__(self):
369369
return len(self._data)
370370

371-
class ByteArrayDesc(object):
372-
373-
def __init__(self):
374-
self.name='[B'
375-
self.serialVersionUID=-5984413125824719648
376-
self.fields_names=[]
377-
self.fields_types=[]
378-
self.flags = 0x2
379-
self.superclass=None
380371

381372
# ------------------------------------------------------------------------------
382373

@@ -1637,3 +1628,14 @@ def create(self, classdesc):
16371628

16381629
log_debug(">>> java_object: {0}".format(java_object))
16391630
return java_object
1631+
1632+
1633+
class ByteArrayDesc(object):
1634+
1635+
def __init__(self):
1636+
self.name = JavaObjectConstants.TYPE_ARRAY + JavaObjectConstants.TYPE_BYTE
1637+
self.serialVersionUID = -5984413125824719648
1638+
self.fields_names = []
1639+
self.fields_types = []
1640+
self.flags = JavaObjectConstants.SC_SERIALIZABLE
1641+
self.superclass = None

tests/bom.ser

445 Bytes
Binary file not shown.

tests/bom.zip

418 Bytes
Binary file not shown.

tests/test_zip.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import javaobj
2+
import logging
3+
import time
4+
5+
def main():
6+
logging.basicConfig(level=logging.DEBUG)
7+
logging.debug('--- %s ---', time.strftime("%H:%M:%S"))
8+
filename = 'bom.zip'
9+
output = 'bom.ser'
10+
marshaller = javaobj.JavaObjectMarshaller()
11+
with open(filename, 'rb') as zip_file:
12+
data = zip_file.read()
13+
javaarray = javaobj.JavaByteArray(data, classdesc=javaobj.ByteArrayDesc())
14+
java_data = marshaller.dump(javaarray)
15+
with open(output, 'wb') as writefile:
16+
writefile.write(java_data)
17+
18+
if __name__ == '__main__':
19+
main()

0 commit comments

Comments
 (0)