Java String Repeat repeat(String in, int count)

Here you can find the source of repeat(String in, int count)

Description

repeat

License

Apache License

Declaration

public static String repeat(String in, int count) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.DecimalFormat;

public class Main {
    public static String repeat(String in, int count) {
        if ((in == null) || (count < 1))
            return "";
        StringBuffer out = new StringBuffer();
        for (int i = 0; i < count; i++) {
            out.append(in);// w  ww. j a v  a 2s .  c o  m
        }
        return out.toString();
    }

    public static String toString(Object[] in) {
        StringBuffer desc = new StringBuffer();
        desc.append("[");
        if (in != null) {
            for (int i = 0; i < in.length; i++) {
                desc.append(in[i]).append(";");
            }
        }
        desc.append("]");
        return desc.toString();
    }

    public static String toString(double in, String format) {
        DecimalFormat formatter = new DecimalFormat(format);
        return formatter.format(in);
    }

    public static String toString(int in, String format) {
        DecimalFormat formatter = new DecimalFormat(format);

        return formatter.format(in);
    }
}

Related

  1. createRepeatedString(char c, int length)
  2. deleteRepeatStr(String repeatStr, String separator)
  3. repeat(String item, int count)
  4. repeat(String pattern, int count)
  5. repeat(String s, int cnt)
  6. repeat(String s, int times)