Thanks Frank, So is MappedByteBuffer is really that fast? Also, I tried your suggestion of using predefined Boolean object -- seems to save at most 3 seconds.
Alex [EMAIL PROTECTED] wrote: > Send Advanced-swing mailing list submissions to > [EMAIL PROTECTED] > > To subscribe or unsubscribe via the World Wide Web, visit > http://eos.dk/mailman/listinfo/advanced-swing > or, via email, send a message with subject or body 'help' to > [EMAIL PROTECTED] > > You can reach the person managing the list at > [EMAIL PROTECTED] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Advanced-swing digest..." > > Today's Topics: > > 1. reading from file ([EMAIL PROTECTED]) > 2. Re: reading from file (Frank D. Greco) > > --__--__-- > > Message: 1 > Date: Wed, 6 Aug 2003 11:44:20 -0400 (EDT) > Subject: reading from file > From: [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > > Hi, > > I have a pipe-delimited file that I want to read from. As I read each line > of file, I tokenize it and put each token in an Object[][]. Everything > works fine, the only problem is that it taks too long to read whole file. > Is there a way to speed up this proccess? > Code is below. > > thanks, > webmacaco > > code: > -------------------------------------------------------------------------------- > > grid = file to read from > example of grid: > - programName|Files|Files|1|1|1|1|1|1|0|1|1|1|1|1|1|1|1|1|0 > - total lines: 245 > - total tokens: 4900 > > code for reading file > --------------------- > Object[][] tableData = new Object[rowNames.size()][columns.length]; > String data = ""; > boolean bool; > String columnLine = ""; > int i,j; > for(i = 0,j = 2; i < rowNames.size(); i++,j++){ > columnLine = grid.getLine(j); > for(int k = 0,m = 4; k < columns.length; k++,m++){ > data = grid.getToken(columnLine,m); > tableData[i][k] = new Boolean(data.equals("0")?false:true); > } > } > > --__--__-- > > Message: 2 > Date: Wed, 06 Aug 2003 23:26:10 -0400 > To: [EMAIL PROTECTED],[EMAIL PROTECTED] > From: "Frank D. Greco" <[EMAIL PROTECTED]> > Subject: Re: reading from file > > At 11:44 AM 8/6/2003 -0400, [EMAIL PROTECTED] wrote: > >I have a pipe-delimited file that I want to read from. As I read each line > >of file, I tokenize it and put each token in an Object[][]. Everything > >works fine, the only problem is that it taks too long to read whole file. > >Is there a way to speed up this proccess? > > Do you really need to create a brand new Boolean for each > element, or do you just merely need to have true and > false for each? If so, why not just use reuse 2 Booleans > and skip the 'new' (which is costly). > > Also its not obvious if "grid" is a buffered stream or not. > Btw, try NIO... specifically MappedByteBuffer. Its pretty fast. > > Frank G. > > --__--__-- > > _______________________________________________ > Advanced-swing mailing list > [EMAIL PROTECTED] > http://eos.dk/mailman/listinfo/advanced-swing > > End of Advanced-swing Digest _______________________________________________ Advanced-swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/advanced-swing