Added fill(), a method to make a string of some character repeated.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@1276 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: StringUtil.java,v 1.59 2003/10/23 16:09:34 eric Exp $
|
// $Id: StringUtil.java,v 1.60 2003/10/24 01:17:51 ray Exp $
|
||||||
//
|
//
|
||||||
// samskivert library - useful routines for java programs
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Michael Bayne
|
// Copyright (C) 2001 Michael Bayne
|
||||||
@@ -138,10 +138,19 @@ public class StringUtil
|
|||||||
* Returns a string containing the requested number of spaces.
|
* Returns a string containing the requested number of spaces.
|
||||||
*/
|
*/
|
||||||
public static String spaces (int count)
|
public static String spaces (int count)
|
||||||
|
{
|
||||||
|
return fill(' ', count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string containing the specified character repeated the
|
||||||
|
* specified number of times.
|
||||||
|
*/
|
||||||
|
public static String fill (char c, int count)
|
||||||
{
|
{
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
for (int ii = 0; ii < count; ii++) {
|
for (int ii = 0; ii < count; ii++) {
|
||||||
buf.append(" ");
|
buf.append(c);
|
||||||
}
|
}
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user