Java Integer Format format(int spaces, String string)

Here you can find the source of format(int spaces, String string)

Description

format

License

Apache License

Declaration

public static String format(int spaces, String string) 

Method Source Code

//package com.java2s;
/**/* w  ww.  ja  v  a  2  s.co  m*/
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    public static String format(int spaces, String string) {
        String format = "%1$-" + spaces + "s";
        return String.format(format, string);
    }
}

Related

  1. format(int i, int fillLength)
  2. format(int i, int length, boolean left_justify, char fill)
  3. format(int intval)
  4. format(int num)
  5. format(int num, int length)
  6. format(int ticks)
  7. formatInt(int i, int radix, int len)
  8. formatInt(int in, int precision)
  9. formatInt(int myint, int maxint)