Results 1 to 5 of 5
  1. #1
    123456 is offline Member
    Join Date
    Jun 2010
    Posts
    6
    Rep Power
    0

    Post String Display problem

    Hi friends,
    I have a long string , and while displaying that string i want to use delimiter, like don't display string after "." is there any way to limit the displaying of our string?

    Thanks in Advance

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    10

    Default

    So, don't display the String, but display the result of some String method.

    for example, instead of
    Java Code:
    System.out.println(str);
    use
    Java Code:
    System.out.println(str.replaceFirst("\\..*$", "");

  3. #3
    123456 is offline Member
    Join Date
    Jun 2010
    Posts
    6
    Rep Power
    0

    Default

    thanks for your rply.. but am using one file as a tree DefaultMutableTreeNode and in my tree it is showing a full name of my File with extension, i want to ignore that extension while displaying... so how it is possible?

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    10

    Default

    The principle is the same, but, of course, you also then, need a TreeRenderer, see the swing tutorials.

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    18,339
    Rep Power
    27

    Default

    Create a substring by locating the last . in the String and choosing all the String up to but not including that last ".".

Similar Threads

  1. How to display Output String in asterix?
    By shalini_priya in forum New To Java
    Replies: 1
    Last Post: 11-24-2009, 12:36 PM
  2. How to display a String that contains more than one white spaces
    By thachun in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 09-27-2009, 09:16 AM
  3. Need to display the jsp variable(String) into html?
    By Arivudai Nambi in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 02-25-2009, 06:44 PM
  4. Cannot display a random string from .dat file
    By explosion242 in forum New To Java
    Replies: 2
    Last Post: 09-18-2008, 01:48 PM
  5. Problem with display in Netbeans 5.5
    By Albert in forum NetBeans
    Replies: 1
    Last Post: 07-13-2007, 03:33 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
  •