|
-
October 8th, 1999, 06:49 AM
#1
FILE READING
Hello Friends
i'm working on java.(JBUilder 3 and JDK1.2)
i need your suggestion for the follwing task..
OBJECTIVE : Getting data(records) from .txt files (tab seperated) and .csv files. and display records in JTable. File size may be 1mb to 5GB.
WHAT I DID for file reading :
BufferedReader in= new BufferedReader( new InputStreamReader ( new FileInputStream(filePath)));
while((s1=in.readLine()) != null) {
// prepare table model
}//end of while
NOTE: THIS IS TAKING LONG TIME (FOR READING 364KB FILE IT'S TAKING 10SECONDS) 64MB RAM && PII
SUGGESTION FROM U:
IS THERE ANY EFFICIENT METHOD TO READ FROM FILE??????????????(As Fast as Possible)
if, please suggest..
Thanx
sat
-
October 12th, 1999, 03:26 AM
#2
Re: FILE READING
Hi,
I think Java is efficient enough in reading from files. The following code takes 1973 milliseconds for 6.022.093 bytes (!!!) of a text file:
import java.io.*;
public class Test
{
public static void main ( String args[] ) throws Exception
{
String s = null;
BufferedReader in = new BufferedReader ( new InputStreamReader ( new FileInputStream ( "test.txt" ) ) );
long start = System.currentTimeMillis ();
while ( ( s = in.readLine () ) != null );
long stop = System.currentTimeMillis ();
System.out.println ( "elapsed=" + ( stop - start ) );
in.close ();
}
}
I think you've got a problem with the handling of your table.
Bye
Axel
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|