You are a guest. Restricted access. Read more.
Command disabled: revisions

Java and Python IO

Native Java IO classes

Read Java IO tutorial

Below we show a simple example of how to use Java classes using Python/Jython syntax for IO:

Code example

  Download for this example is disabled for non-members
1: from import *
2: fo=FileOutputStream('data.d')
3: out=DataOutputStream(BufferedOutputStream( fo ))
4: list=[1.,2.,3.,4.,5.]
5: for a in list:
6:    out.writeFloat(a)
7: out.close()
8: fo.close()

Native Python IO

Read Python IO tutorial Below we show an example of how to write a list of numbers using the Python class “pickle” for IO:

>>> import pickle
>>> f=open('data.pic','w')
>>> pickle.dump([1,2,3,4],f)
>>> f.close()

I/O performance and benchmarks

Here we compare performance of the PFile and HFile classes for read and write mode. Benchmark results are given together with the code.

Unregistered users have a limited access to this section. You can unlock advanced pages after becoming a full member.

Third-party IO classes

click here if you want to know more

click here if you want to know more

click here if you want to know more

here are a lot of other Java-based I/O classes designed for storing and retrieving data. A complete description of how to use Java, Jython and SCaVis for scientific analysis is described in the book Scientific data analysis using Jython and Java published by Springer Verlag, London, 2010 (by S.V.Chekanov)

Sergei Chekanov 2010/03/07 17:35