Java Number Min Value min(String in, int len)

Here you can find the source of min(String in, int len)

Description

min

License

Open Source License

Declaration

public static String min(String in, int len) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String min(String in, int len) {
        return min(in, len, ' ');
    }/*from w  w w.j a v a  2  s.  c  om*/

    public static String min(String in, int len, char c) {
        return padLast(in, len, c);
    }

    public static String padLast(String string, int len, char c) {
        if (string.length() >= len)
            return string;
        StringBuilder sb = new StringBuilder(len);
        sb.append(string);
        while (sb.length() < len)
            sb.append(c);
        return sb.toString();
    }

    public static String toString(char c) {
        return new String(new char[] { c });
    }

    public static String toString(int[] o) {
        StringBuilder sb = new StringBuilder();
        sb.append('[');
        sb.append(o[0]);
        for (int i = 1; i < o.length; i++) {
            sb.append(',');
            sb.append(o[i]);
        }
        sb.append(']');
        return sb.toString();
    }

    public static String toString(short[] o) {
        StringBuilder sb = new StringBuilder();
        sb.append('[');
        sb.append(o[0]);
        for (int i = 1; i < o.length; i++) {
            sb.append(',');
            sb.append(o[i]);
        }
        sb.append(']');
        return sb.toString();
    }

    public static String toString(float[] o) {
        StringBuilder sb = new StringBuilder();
        sb.append('[');
        sb.append(o[0]);
        for (int i = 1; i < o.length; i++) {
            sb.append(',');
            sb.append(o[i]);
        }
        sb.append(']');
        return sb.toString();
    }

    public static String toString(long[] o) {
        StringBuilder sb = new StringBuilder();
        sb.append('[');
        sb.append(o[0]);
        for (int i = 1; i < o.length; i++) {
            sb.append(',');
            sb.append(o[i]);
        }
        sb.append(']');
        return sb.toString();
    }

    public static String toString(double[] o) {
        StringBuilder sb = new StringBuilder();
        sb.append('[');
        sb.append(o[0]);
        for (int i = 1; i < o.length; i++) {
            sb.append(',');
            sb.append(o[i]);
        }
        sb.append(']');
        return sb.toString();
    }

    public static String toString(boolean[] o) {
        StringBuilder sb = new StringBuilder();
        sb.append('[');
        sb.append(o[0]);
        for (int i = 1; i < o.length; i++) {
            sb.append(',');
            sb.append(o[i]);
        }
        sb.append(']');
        return sb.toString();
    }

    public static String toString(char[] o) {
        StringBuilder sb = new StringBuilder();
        sb.append('[');
        sb.append(o[0]);
        for (int i = 1; i < o.length; i++) {
            sb.append(',');
            sb.append(o[i]);
        }
        sb.append(']');
        return sb.toString();
    }

    public static String toString(Object o) {
        return o == null ? "null" : o.toString();
    }

    public static String toString(Object[] o) {
        if (isEmpty(o))
            return "[]";

        StringBuilder sb = new StringBuilder();
        sb.append('[');
        sb.append(toString(o[0]));
        for (int i = 1; i < o.length; i++) {
            sb.append(',');
            sb.append(toString(o[i]));
        }
        sb.append(']');
        return sb.toString();
    }

    public static boolean isEmpty(CharSequence cs) {
        return cs == null || cs.length() == 0;
    }

    public static boolean isEmpty(Object[] o) {
        return o == null || o.length == 0;
    }
}

Related

  1. min(Number num1, Number num2)
  2. Min(Object in)
  3. min(Object o1, Object o2)
  4. min(String a, String b)
  5. min(String a, String b)
  6. min(String name)
  7. min(String s)
  8. min(T a, T b)
  9. min(T a, T b)