CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: FILE READING

  1. #1
    Join Date
    Jul 1999
    Posts
    47

    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



  2. #2
    Join Date
    Oct 1999
    Location
    Germany
    Posts
    8

    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
  •  





Click Here to Expand Forum to Full Width

Featured