/    Sign up×
Community /Pin to ProfileBookmark

display x number of characters

If i have a string that has 5000 characters in it from my database, when I display that to the user, how can I only show, for example, the first 200 characters?

thanks

to post a comment
Java

1 Comments(s)

Copy linkTweet thisAlerts:
@VeerasekarFeb 10.2007 — Hello jrthor2,

I dont know, which database are you using. Anyway, I wrote a program for your reuirement. Its may be helpful for you.


class PickXCharacters{

public static void main(String args[])

{

// Assign a String data in to String Variable

//If you are using a Database, Get a Data from DB and Assign into the


// String Variable

String strData=

"The UN security council criticised President Rajapakse for destroying"+


"the 2002 truce by trying to reoccupy the areas recognised as "+

"under Tiger control.";

// Gets first 50 characters from the String

String strPick=strData.substring(0, 49);

System.out.println("First 50 Characters as follows => "+strPick);

}

}


PanchatcharamVeerasekar

ClimbInc,Tokyo,Japan
×

Success!

Help @jrthor2 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...