|
From: Hasan D. <has...@gm...> - 2007-08-15 17:03:05
|
On 15/08/07, pompeez <kaj...@gm...> wrote: > I need to write a Java Array/ArrayList/List to a text file in Jython. I used > the .write() function, but it is letting me write only a string. Make sure the elements contained in the ArrayList implement java.io.Serializable and then: from java.io import File, ObjectOutputStream, FileOutputStream # ArrayList a = ArrayList() # a.add(1) # ... f=File.createTempFile("prefix", ".ext") fos=FileOutputStream(f) oos=ObjectOutputStream(fos) oos.writeObject(a) oos.flush() oos.close() fos.close() f.deleteOnExit(0) print f.name+'\n' Hope that's sorted. -- Cheers, Hasan Diwan <has...@gm...> |