Results 1 to 8 of 8
  1. #1
    yap_1991 is offline Member
    Join Date
    Apr 2010
    Posts
    19
    Rep Power
    0

    Unhappy File Extraction using Java

    I need help in writing a program which can download a database from pdb web and updates automatically, it should be able to extract that information that I need from the database.I need help in this. Thank you!

    the current codes that i have are as follow:

    Java Code:
    /**
     * @(#)lol.java
     *
     *
     * @author 
     * @version 1.00 2010/4/26
     */
    
    
    import java.io.*;
    class FileRead 
    {
       public static void main(String args[])
      {
          try{
        // Open the file that is the first 
        // command line parameter
        FileInputStream fstream = new FileInputStream("2RQV.pdb");
        // Get the object of DataInputStream
        DataInputStream in = new DataInputStream(fstream);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        String strLine;//Read File Line By Line
        
        while ((strLine = br.readLine()) != null)   
        {
          System.out.println (strLine);// Print the content on the console
        }
       
        //Close the input stream
        in.close();
        }catch (Exception e){//Catch exception if any
          System.err.println("Error: " + e.getMessage());
        }
      }
    }
    Last edited by Eranga; 04-27-2010 at 06:14 AM. Reason: code tags added

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Please use code tags when you are posting code segment here in the forum. If you don't know how to do that please check on my signature. You can find a link to the relevant help document.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    About your question. So what happen when you run your code? Any errors? Please explain your question more clearly with relevant details. Otherwise it's difficult to answer lol. No one wants to test your code and fix the bugs.

  4. #4
    yap_1991 is offline Member
    Join Date
    Apr 2010
    Posts
    19
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    About your question. So what happen when you run your code? Any errors? Please explain your question more clearly with relevant details. Otherwise it's difficult to answer lol. No one wants to test your code and fix the bugs.
    When i run the code using jcreator, the file it reads from keeps getting read continuously, is there a way for me to change the codes just for it to show once?

    and do you know how i can create a program that I can extract a certain part of the text file to get the information i want?

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    You mean the following is infinitely executed ?

    Java Code:
        while ((strLine = br.readLine()) != null)   
        {
          System.out.println (strLine);// Print the content on the console
        }
    So what could be happen there? What that code segment do, can you identify?

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by yap_1991 View Post
    and do you know how i can create a program that I can extract a certain part of the text file to get the information i want?
    To read a part of a file, then your file must have some kind of an information to track that which part you want to read. Because Java programs are not intelligence to find what you really want, you cannot do that in Java. So what you've to do is pick that information and proceed from there.

    Did you have tried anything related to that, mean reading the part of the file?

  7. #7
    yap_1991 is offline Member
    Join Date
    Apr 2010
    Posts
    19
    Rep Power
    0

    Default

    I've tried reading the whole file, but now I'm trying to have the program read part of the file and printing it on a new file. Meaning, I should have one original file containing all information followed by a new file containing the information I want. Do you know to go about doing it in java?

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. JAVA Video Extraction
    By KSadeck in forum Advanced Java
    Replies: 3
    Last Post: 01-08-2009, 08:43 AM
  2. web extraction
    By murali in forum Networking
    Replies: 3
    Last Post: 12-13-2008, 08:10 AM
  3. To open an image file such as Jpeg file using JAva Program
    By itmani2020 in forum Advanced Java
    Replies: 10
    Last Post: 07-11-2008, 10:57 AM
  4. Replies: 7
    Last Post: 05-23-2008, 04:46 AM
  5. Replies: 1
    Last Post: 02-04-2008, 09:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •