Useful function to create a string with N copies of a same char

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@784 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
depristo 2009-05-21 22:23:52 +00:00
parent 287bb52e81
commit d261459c48
1 changed files with 6 additions and 0 deletions

View File

@ -381,6 +381,12 @@ public class Utils {
public static double percentage(int x, int base) { return (base> 0 ? ((double)x/(double)base)*100.0 : 0); }
public static double percentage(long x, long base) { return (base> 0 ? ((double)x/(double)base)*100.0 : 0); }
public static String dupString( char c, int nCopies ) {
char[] chars = new char[nCopies];
for ( int i = 0; i < nCopies; i++ ) chars[i] = c;
//System.out.printf("chars is %s%n", new String(chars));
return new String(chars);
}
public static int countOccurances(char c, String s) {
int count = 0;