Results 1 to 5 of 5
  1. #1
    ollyworks is offline Member
    Join Date
    Sep 2009
    Posts
    5
    Rep Power
    0

    Unhappy Need to read an .ini and .abook file line by line (both files contain texts)

    Hi,

    All I need to do is to make this Applet works. Assuming the Applet is signed (I already know how to sign an Applet).

    Java Code:
     
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.Applet;
    import java.io.*;
     
    	public class ContactImporter_V2 extends java.applet.Applet {
     
    		public void paint(java.awt.Graphics contexteGraphique){
     
    			String windows_login = windows_login = System.getProperty("user.name");
     
    			String th_profile_path_1 = "C:\\Documents and Settings\\" + windows_login + "\\Application Data\\Thunderbird\\Profiles\\";
    			String th_profile_path_2 = "C:\\Utilisateurs\\" + windows_login + "\\Appdata\\Roaming\\Thunderbird\\Profiles\\" ;
    			String th_profile_path_3 = "C:\\Users\\" + windows_login + "\\Appdata\\Roaming\\Thunderbird\\Profiles\\";
     
    			String th_profile_ini_1 = th_profile_path_1 + "profiles.ini";
    			String th_profile_ini_2 = th_profile_path_2 + "profiles.ini";
    			String th_profile_ini_3 = th_profile_path_3 + "profiles.ini";
     
    			File fileHnd1 = new File(th_profile_ini_1);
    			File fileHnd2 = new File(th_profile_ini_2);
    			File fileHnd3 = new File(th_profile_ini_3);
     
    			if( fileHnd1.canRead() )
    			{
                                      // Read each line into the file
                                      // If line contains "Path=Profiles/" then
                                      // retrieve string that comes after "Path=Profiles/"
                                     
    			}
    			else if( fileHnd2.canRead() )
    			{
                                      // Read each line into the file
                                      // If line contains "Path=Profiles/" then
                                      // retrieve string that comes after "Path=Profiles/"
    			}
    			else if( fileHnd3.canRead() )
    			{
                                      // Read each line into the file
                                      // If line contains "Path=Profiles/" then
                                      // retrieve string that comes after "Path=Profiles/"
    			}
    		}
     
    	}
    Thx a lot for your help!

    Stephane

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    What do you mean by make it work?
    What does it do now and what do you want it to do instead?

  3. #3
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    765
    Rep Power
    6

    Default

    The above code is not understandable.But,I can give small suggestion for reading .ini file.

    Generally .ini files contain key value pairs

    Ex:test.ini
    Name = Ramya
    Place = Chennai

    In java using Properties you can load the ini file and using getProperty() method u can retreive the value associated with the key.

    Gothru the piece of code below
    ------------------------------
    Properties p = new Properties();
    p.load(new FileInputStream(new File("test.ini")));
    System.out.println(p.getProperty("Place"));
    Ramya:cool:

  4. #4
    ollyworks is offline Member
    Join Date
    Sep 2009
    Posts
    5
    Rep Power
    0

    Default

    Well, all I need to do is to get the content of a file which path may look like the paths below where "stephane" is the windows session username (I read somewhere that I can get this username using System.getProperty("user.name"); ):

    Java Code:
    C:\Documents and Settings\stephane\Application Data\Thunderbird\Profiles\h93ya70s.default\abouk.mab
    OR

    Java Code:
    C:\Utilisateurs\stephane\Appdata\Roaming\Thunderbird\Profiles\h93ya70s.default\abouk.mab
    OR

    Java Code:
    C:\Users\stephane\Appdata\Roaming\Thunderbird\Profiles\h93ya70s.default\abouk.mab
    If there is a direct way to look for such a file and read its content it will be good!

    Well, this is the Thunderbird address book and I'm coding an Applet allowing the user of my website to import their Thunderbird addresses book!

  5. #5
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

Similar Threads

  1. [SOLVED] read last line
    By Azndaddy in forum New To Java
    Replies: 22
    Last Post: 04-22-2012, 09:22 PM
  2. How to make Scanner read the same line
    By mcollins in forum New To Java
    Replies: 2
    Last Post: 03-03-2009, 06:41 AM
  3. Data files - how to read random line?
    By Exhonour in forum New To Java
    Replies: 4
    Last Post: 01-20-2009, 08:28 PM
  4. read the file from different line number
    By vaskarbasak in forum Advanced Java
    Replies: 3
    Last Post: 06-02-2008, 01:31 PM
  5. Reading in data from file line by line
    By bluekswing in forum New To Java
    Replies: 1
    Last Post: 10-02-2007, 12:19 AM

Posting Permissions

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