Page 2 of 2 FirstFirst 12
Results 21 to 30 of 30
  1. #21
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,305
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by stevenpalomino View Post
    ah. it says C:/contacts.txt. how would I change that to a Mac relevant system?
    Check the String values for 'dir' and 'FILE_NAME' and change them accordingly. My guess is that dir= "C:/" so it should be changed to "/" for a quick hack. Your friend put a windowism in the code by giving variable 'dir' that value. I wonder if you can create a file in the root directory of your file system ...

    kind regards.

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  2. #22
    Join Date
    Jun 2011
    Posts
    21
    Rep Power
    0

    Default

    that's strange I don't see anything like that. Here is the pastebin of the whole file.

    [Java] import java.io.File; import java.io.FileWriter; import java.io.IOException; impo - Pastebin.com

  3. #23
    Join Date
    Jun 2011
    Posts
    21
    Rep Power
    0

    Default

    what I mean is that there is not dir= or anything like that.

  4. #24
    Join Date
    Jun 2011
    Posts
    21
    Rep Power
    0

    Default

    What do I need to add then? and where?

  5. #25
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,305
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by stevenpalomino View Post
    what I mean is that there is not dir= or anything like that.
    This is the first part of your own file:

    Java Code:
    public class ContactFileDAO {
    
            private final String FILE_NAME = "Contacts.txt";
            private String dir;
            
            public ContactFileDAO(String dir) {
    
                    this.dir = dir;
    
            }
    The value for 'dir' is passed in to the constructor of your object. Check the rest of your code where such an object is created and change the parameter value. (of fiddle with the result to get rid of the C: part).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #26
    Join Date
    Jun 2011
    Posts
    21
    Rep Power
    0

    Default

    Thanks!!

    Changed:
    File file = new File(dir + FILE_NAME);

    to:
    File file = new File("Contacts.txt");
    and worked great!

  7. #27
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,305
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by stevenpalomino View Post
    Thanks!!

    Changed:
    File file = new File(dir + FILE_NAME);

    to:
    File file = new File("Contacts.txt");
    and worked great!
    I don't think I like that solution: now your file will always be created in the current working directory (the 'dir' value is ignored); better get rid of the 'windowism' and remove the first character of the file name (plus directory) if the second character is a colon (:) character.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #28
    Join Date
    Jun 2011
    Posts
    21
    Rep Power
    0

    Default

    I'm sorry. I just don't get what I'm supposed to change :S

  9. #29
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,305
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by stevenpalomino View Post
    I'm sorry. I just don't get what I'm supposed to change :S
    Read the API documentation for the String class and see if there are some methods that can help you to chop off "C:" from the String "C:\Contacts.txt".

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  10. #30
    srid12 is offline Member
    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0

    Default

    because main is not a class . whenever u name a class name for running , jvm will look for main method in the given class name . please see Moderator edit: link removed
    Last edited by DarrylBurke; 06-25-2011 at 05:14 PM. Reason: Removed link

Page 2 of 2 FirstFirst 12

Similar Threads

  1. BufferedReader throwing strange error
    By DragonGhola in forum Advanced Java
    Replies: 4
    Last Post: 06-16-2011, 10:17 AM
  2. Strange Compilation Error About Generics
    By dhafirnz in forum Advanced Java
    Replies: 7
    Last Post: 11-16-2010, 08:54 AM
  3. Strange Error
    By AJArmstron@aol.com in forum New To Java
    Replies: 1
    Last Post: 04-18-2010, 09:31 PM
  4. Strange eclipse behaviour with new version
    By KingOfLions in forum Eclipse
    Replies: 0
    Last Post: 09-10-2009, 01:42 PM
  5. strange Error message
    By little_polarbear in forum New To Java
    Replies: 4
    Last Post: 08-25-2008, 11:45 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
  •