Results 1 to 5 of 5
  1. #1
    sc08dr is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Default return David when C://Users//David is passed in

    I want to chop a string to return the last word in a pathname.

    example

    C://Users//David//My Documents

    would return My Documents

    Any ideas would be really apreciated

  2. #2
    FlipPoker@gmail.com is offline Senior Member
    Join Date
    Mar 2011
    Posts
    103
    Rep Power
    0

    Default

    Check out the File class. There is a method called getName() that will give you what you want.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default

    Read the API for String, there's more than one way you can do this.

    You can also do it with the File API.

    db

  4. #4
    Iron Lion is offline Senior Member
    Join Date
    Nov 2010
    Posts
    210
    Rep Power
    4

    Default

    Alternatively, you could use the substring() and lastIndexOf() methods of String. (Edit: beaten to it)

  5. #5
    sc08dr is offline Member
    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

Similar Threads

  1. Max size for a passed parameter?
    By ravl10 in forum New To Java
    Replies: 3
    Last Post: 01-29-2010, 06:27 PM
  2. entities are passed by value or passed by reference
    By syntrax in forum New To Java
    Replies: 1
    Last Post: 12-17-2009, 07:13 AM
  3. java certification passed
    By natasha in forum Java Certification
    Replies: 0
    Last Post: 12-05-2009, 08:24 AM
  4. Cannot get passed these syntax errors
    By MrKP in forum New To Java
    Replies: 1
    Last Post: 05-12-2008, 07:05 AM
  5. Null array when passed to MouseListener
    By stevemcc in forum New To Java
    Replies: 2
    Last Post: 04-02-2008, 10:42 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
  •