DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2006
    Posts
    3

    Exclamation to select certain details from text file

    hi,
    i was wondering how can i select n display only certain items from the text file. lets say i have name , address, birthdate, location in the file.
    However, i would only like to retrieve the address. how can i do that? thanks

    currently i have managed to select out all the info by using this following codes.


    File inputFile = new File("C:\\temp\\test.txt");
    try{
    FileReader in= new FileReader(inputFile);
    int c;
    String str;

    while ((c = in.read()) != -1) {
    System.out.print((char) c);

    }
    in.close();

    }catch (FileNotFoundException e){
    System.out.println("File Does not exist");
    System.exit(1);

  2. #2
    Join Date
    Dec 2005
    Posts
    97
    what does the data in the file look like?
    is it something like:
    "Name: John
    Address: 123 something st.
    Birthdate: 12/3/78"

    or is it something else?

  3. #3
    Join Date
    Nov 2006
    Posts
    3

    Exclamation

    it looks like this.

    name age location

    john 13 usa
    peter 14 au
    jane 15 seoul

    lets say i would only like to select out the age.how do i do tht?
    thanks

  4. #4
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    The Scanner class is designed to perform the very task you are looking at.

  5. #5
    Join Date
    Nov 2006
    Posts
    3
    where can i find it?
    thanks

  6. #6
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    Take a look at the API documentation

    http://java.sun.com/j2se/1.5.0/docs/api/

Similar Threads

  1. Replies: 5
    Last Post: 08-18-2006, 01:15 PM
  2. How long before the next version??
    By _CAG in forum .NET
    Replies: 146
    Last Post: 08-12-2002, 10:40 PM
  3. open text file using shell
    By Hian Chew in forum VB Classic
    Replies: 18
    Last Post: 03-07-2001, 12:07 PM
  4. open text file using shell
    By Hian Chew in forum VB Classic
    Replies: 0
    Last Post: 03-06-2001, 12:28 PM
  5. Replies: 0
    Last Post: 04-17-2000, 01:33 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links