From: Charlie G. <cha...@gm...> - 2008-01-17 20:02:41
|
It is. You could do the same thing as Jeff in Python using seek: >>> a = open('blah', 'w') >>> a.seek(1024 * 1024 * 10) >>> a.write('\x00') >>> a.close() Charlie On Jan 17, 2008 11:50 AM, Jesse Millan <j.L...@gm...> wrote: > Correct me if I'm wrong, but in this case, isn't the entire string is > stored in memory? > > > On Jan 17, 2008 11:46 AM, Gert-Jan <jy...@gj...> wrote: > > You can also use a 'python only' version > > > > filOutput = file('textfile', 'w') > > filOutput.write('a'*10*1024*1024) > > filOutput.close() > > > > This file is filled with 'a's and 10MB. (Using a single-byte > > codepage/encoding) > > > > > > > > Jeff Emanuel schreef: > > > > > This works pretty fast, but it fills the file with zeros, > > > not text. > > > > > > >>> import java > > > >>> raf=java.io.RandomAccessFile("path_to_file","rw") > > > >>> raf.setLength(1024*1024*10) > > > >>> raf.close() > > > > > > > > > Jesse Millan wrote: > > >> All, > > >> > > >> I'm looking for an efficient way to create a large dummy file in > > >> jython. It'll need to be created and filled with about 10 MB of > > >> (arbitrary - preferably text) data all at once. Obviously using a for > > >> loop and calling PyFile.write("a") ten million times is a bad idea > > >> memory wise... any suggestions? > > >> > > >> Thanks! > > >> > > >> -Jesse > > >> > > >> ------------------------------------------------------------------------- > > >> This SF.net email is sponsored by: Microsoft > > >> Defy all challenges. Microsoft(R) Visual Studio 2008. > > >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > >> _______________________________________________ > > >> Jython-users mailing list > > >> Jyt...@li... > > >> https://lists.sourceforge.net/lists/listinfo/jython-users > > > > > > ------------------------------------------------------------------------- > > > This SF.net email is sponsored by: Microsoft > > > Defy all challenges. Microsoft(R) Visual Studio 2008. > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > > _______________________________________________ > > > Jython-users mailing list > > > Jyt...@li... > > > https://lists.sourceforge.net/lists/listinfo/jython-users > > > > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Microsoft > > Defy all challenges. Microsoft(R) Visual Studio 2008. > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > _______________________________________________ > > Jython-users mailing list > > Jyt...@li... > > https://lists.sourceforge.net/lists/listinfo/jython-users > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |