Source Code : Locates the end of the word at the specified position.
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Locates the end of the word at the specified position.
/*
* TextUtilities.java - Utility functions used by the text area classes
* Copyright (C) 1999 Slava Pestov
*
* You may use and modify this package for any purpose. Redistribution is
* permitted, in both source and binary form, provided that this notice
* remains intact in all source distributions of this package.
*/
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
/**
* Class with several utility functions used by the text area component.
*
* @author Slava Pestov
* @version $Id$
*/
public class TextUtilities
{
/**
* Locates the end of the word at the specified position.
*
* @param line
* The text
* @param pos
* The position
*/
public static int findWordEnd( String line, int pos, String noWordSep )
{
char ch = line.charAt( pos );
if( noWordSep == null )
noWordSep = "";
boolean selectNoLetter = ( !Character.isLetterOrDigit( ch ) && noWordSep.indexOf( ch ) == -1 );
int wordEnd = line.length();
for( int i = pos; i < line.length(); i++ )
{
ch = line.charAt( i );
if( selectNoLetter ^ ( !Character.isLetterOrDigit( ch ) && noWordSep.indexOf( ch ) == -1 ) )
{
wordEnd = i;
break;
}
}
return wordEnd;
}
}
Thank with us