File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes substring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "substring" Watch "substring" New topic


smitha mano
Ranch Hand

Joined: Sep 26, 2005
Posts: 70
i have EMP database in a field history contains 500 charactes.
i want to display first 125 characters
How to do this using Java?
Ravi Shankar R

Joined: Jan 05, 2005
Posts: 7

public class DemoDisplay {

public static void main(String[] args) {
// Let this be the output String retrieved from the database EMP
String word = "123456789";
int worldLenght = word.length();
int end = worldLenght - (worldLenght - 3);
// Would retieve the first 3 characters of the String word.
String sub = word.substring(0, end);
System.out.println("sub :: " + sub);

I hope this helps you ......

With Regards,
smitha mano
Ranch Hand

Joined: Sep 26, 2005
Posts: 70
thanks very much
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: substring
It's not a secret anymore!