Pages

Thursday, January 7, 2010

Bulding Strings from Char and Bytes

Following is the definition of a over loaded function named buildString that shall help you to build strings from characters, character arrays, bytes and byte arrays

public String buildString(char chars[]){
String returnString=null;
returnString=new String(chars);
return returnString;
}

public String buildString(char chars[],int startIndex, int numOfChars){
String returnString=null;
returnString=new String(chars,startIndex,numOfChars);
return returnString;
}

public String buildString(byte bytes[]){
String returnString=null;
returnString=new String(bytes);
return returnString;
}

public String buildString(byte bytes[],int startIndex,int numOfChars){
String returnString=null;
returnString=new String(bytes,startIndex,numOfChars);
return returnString;
}

No comments:

Post a Comment