I am using a TextArea for displaying data and then...
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   kzi_kzi
Posted On:   Saturday, March 17, 2001 01:20 AM

I am using a TextArea for displaying data and then using substring i am cutting particular data and displaying in another field.

Now when i am substring the data say (25 characters), if the data is having tab, substring is ignoring tab width and it is cutting the particular width (25 characters) excluding the tab width.

Is there any other function, which will help me in getting the tab width also when substring the data ? Or pl. suggest me how to get the data with tab while cutting the data?

Thanks.

Re: I am using a TextArea for displaying data and then...

Posted By:   rajjan_js  
Posted On:   Wednesday, March 28, 2001 10:13 PM





Hi i wrote one own class and a mehtod for your problem . Take it use the method in awt program.


/********class :splitString***********/
/********Author:Rajjan.j.s************/
/********Date :29-03-2001************/

class splitString{
public static void main(String []a)
{
String ar="hi i am a user";
System.out.println(" "+ar);

System.out.println(" "+methodSplitString(ar,3,5)); // call the method here

}

/******** this is the method which will return the string from the given starting index
and the total number of characters **********************/


public static String methodSplitString(String iniString,int startIndex , int totalChar)
{

//int len=iniString.length;
String finalString="";

iniString=iniString+1; // make the first char at '1' because String index start from zero

/* trims the blank spaces before the starting index position */

while( iniString.charAt(startIndex) != ' ')
{
startIndex++;
}

int i=startIndex;
int j=0;

/* extraction will be done here */

while(j!=totalChar)
{


if(iniString.charAt(i) == ' ')
{
// nothing // totalChar++;
}
else{
finalString+=""+iniString.charAt(i);
j++;

}
i++;
}
return finalString;


}

}



About | Sitemap | Contact