summaryrefslogtreecommitdiff
path: root/src/jvm14-library/scala/runtime/RichString.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/jvm14-library/scala/runtime/RichString.scala')
-rw-r--r--src/jvm14-library/scala/runtime/RichString.scala22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/jvm14-library/scala/runtime/RichString.scala b/src/jvm14-library/scala/runtime/RichString.scala
index 2496ddc64b..f38b79cc92 100644
--- a/src/jvm14-library/scala/runtime/RichString.scala
+++ b/src/jvm14-library/scala/runtime/RichString.scala
@@ -224,6 +224,28 @@ final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char
self.getChars(0, length, result, 0)
result
}
+
+
+ /** <p>
+ * Uses the underlying string as a pattern (in a fashion similar to
+ * printf in C), and uses the supplied arguments to fill in the
+ * holes. Only works on Java 1.5 or higher!
+ * </p>
+ * <p>
+ * The interpretation of the formatting patterns is described in
+ * <a href="" target="contentFrame" class="java/util/Formatter">
+ * <code>java.util.Formatter</code></a>.
+ * </p>
+ *
+ * @param args the arguments used to instantiating the pattern.
+ * @throws java.lang.IllegalArgumentException
+ */
+ def format(args : Any*) : String = {
+ val m = classOf[String].getDeclaredMethod("format", classOf[String], classOf[Array[Object]])
+ m.invoke(null, self,
+ args.asInstanceOf[scala.runtime.BoxedObjectArray].
+ unbox(args.getClass).asInstanceOf[Array[Object]]).asInstanceOf[String]
+ }
}
object RichString {