티스토리 뷰

공부

[JDK 17] MessageFormat

승가비 2023. 12. 9. 19:14
728x90

The following example creates a MessageFormat instance that can be used repeatedly:

 int fileCount = 1273;
 String diskName = "MyDisk";
 Object[] testArgs = {new Long(fileCount), diskName};

 MessageFormat form = new MessageFormat(
     "The disk \"{1}\" contains {0} file(s).");

 System.out.println(form.format(testArgs));
 

The output with different values for fileCount:

 The disk "MyDisk" contains 0 file(s).
 The disk "MyDisk" contains 1 file(s).
 The disk "MyDisk" contains 1,273 file(s).

 

https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/text/MessageFormat.html

 

MessageFormat (Java SE 17 & JDK 17)

All Implemented Interfaces: Serializable, Cloneable public class MessageFormat extends Format MessageFormat provides a means to produce concatenated messages in a language-neutral way. Use this to construct messages displayed for end users. MessageFormat t

docs.oracle.com

 

728x90
댓글