From d261459c488ed86cf41ccf12e9d6b7338631a1ef Mon Sep 17 00:00:00 2001 From: depristo Date: Thu, 21 May 2009 22:23:52 +0000 Subject: [PATCH] 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 --- java/src/org/broadinstitute/sting/utils/Utils.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/java/src/org/broadinstitute/sting/utils/Utils.java b/java/src/org/broadinstitute/sting/utils/Utils.java index 29ada1b24..615c9cacd 100755 --- a/java/src/org/broadinstitute/sting/utils/Utils.java +++ b/java/src/org/broadinstitute/sting/utils/Utils.java @@ -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;