src/share/classes/java/io/PrintWriter.java

Print this page




 767      * args)</tt> behaves in exactly the same way as the invocation
 768      *
 769      * <pre>
 770      *     out.format(format, args) </pre>
 771      *
 772      * @param  format
 773      *         A format string as described in <a
 774      *         href="../util/Formatter.html#syntax">Format string syntax</a>.
 775      *
 776      * @param  args
 777      *         Arguments referenced by the format specifiers in the format
 778      *         string.  If there are more arguments than format specifiers, the
 779      *         extra arguments are ignored.  The number of arguments is
 780      *         variable and may be zero.  The maximum number of arguments is
 781      *         limited by the maximum dimension of a Java array as defined by
 782      *         <cite>The Java&trade; Virtual Machine Specification</cite>.
 783      *         The behaviour on a
 784      *         <tt>null</tt> argument depends on the <a
 785      *         href="../util/Formatter.html#syntax">conversion</a>.
 786      *
 787      * @throws  IllegalFormatException
 788      *          If a format string contains an illegal syntax, a format
 789      *          specifier that is incompatible with the given arguments,
 790      *          insufficient arguments given the format string, or other
 791      *          illegal conditions.  For specification of all possible
 792      *          formatting errors, see the <a
 793      *          href="../util/Formatter.html#detail">Details</a> section of the
 794      *          formatter class specification.
 795      *
 796      * @throws  NullPointerException
 797      *          If the <tt>format</tt> is <tt>null</tt>
 798      *
 799      * @return  This writer
 800      *
 801      * @since  1.5
 802      */
 803     public PrintWriter printf(String format, Object ... args) {
 804         return format(format, args);
 805     }
 806 
 807     /**


 818      * @param  l
 819      *         The {@linkplain java.util.Locale locale} to apply during
 820      *         formatting.  If <tt>l</tt> is <tt>null</tt> then no localization
 821      *         is applied.
 822      *
 823      * @param  format
 824      *         A format string as described in <a
 825      *         href="../util/Formatter.html#syntax">Format string syntax</a>.
 826      *
 827      * @param  args
 828      *         Arguments referenced by the format specifiers in the format
 829      *         string.  If there are more arguments than format specifiers, the
 830      *         extra arguments are ignored.  The number of arguments is
 831      *         variable and may be zero.  The maximum number of arguments is
 832      *         limited by the maximum dimension of a Java array as defined by
 833      *         <cite>The Java&trade; Virtual Machine Specification</cite>.
 834      *         The behaviour on a
 835      *         <tt>null</tt> argument depends on the <a
 836      *         href="../util/Formatter.html#syntax">conversion</a>.
 837      *
 838      * @throws  IllegalFormatException
 839      *          If a format string contains an illegal syntax, a format
 840      *          specifier that is incompatible with the given arguments,
 841      *          insufficient arguments given the format string, or other
 842      *          illegal conditions.  For specification of all possible
 843      *          formatting errors, see the <a
 844      *          href="../util/Formatter.html#detail">Details</a> section of the
 845      *          formatter class specification.
 846      *
 847      * @throws  NullPointerException
 848      *          If the <tt>format</tt> is <tt>null</tt>
 849      *
 850      * @return  This writer
 851      *
 852      * @since  1.5
 853      */
 854     public PrintWriter printf(Locale l, String format, Object ... args) {
 855         return format(l, format, args);
 856     }
 857 
 858     /**


 862      *
 863      * <p> The locale always used is the one returned by {@link
 864      * java.util.Locale#getDefault() Locale.getDefault()}, regardless of any
 865      * previous invocations of other formatting methods on this object.
 866      *
 867      * @param  format
 868      *         A format string as described in <a
 869      *         href="../util/Formatter.html#syntax">Format string syntax</a>.
 870      *
 871      * @param  args
 872      *         Arguments referenced by the format specifiers in the format
 873      *         string.  If there are more arguments than format specifiers, the
 874      *         extra arguments are ignored.  The number of arguments is
 875      *         variable and may be zero.  The maximum number of arguments is
 876      *         limited by the maximum dimension of a Java array as defined by
 877      *         <cite>The Java&trade; Virtual Machine Specification</cite>.
 878      *         The behaviour on a
 879      *         <tt>null</tt> argument depends on the <a
 880      *         href="../util/Formatter.html#syntax">conversion</a>.
 881      *
 882      * @throws  IllegalFormatException
 883      *          If a format string contains an illegal syntax, a format
 884      *          specifier that is incompatible with the given arguments,
 885      *          insufficient arguments given the format string, or other
 886      *          illegal conditions.  For specification of all possible
 887      *          formatting errors, see the <a
 888      *          href="../util/Formatter.html#detail">Details</a> section of the
 889      *          Formatter class specification.
 890      *
 891      * @throws  NullPointerException
 892      *          If the <tt>format</tt> is <tt>null</tt>
 893      *
 894      * @return  This writer
 895      *
 896      * @since  1.5
 897      */
 898     public PrintWriter format(String format, Object ... args) {
 899         try {
 900             synchronized (lock) {
 901                 ensureOpen();
 902                 if ((formatter == null)


 922      * @param  l
 923      *         The {@linkplain java.util.Locale locale} to apply during
 924      *         formatting.  If <tt>l</tt> is <tt>null</tt> then no localization
 925      *         is applied.
 926      *
 927      * @param  format
 928      *         A format string as described in <a
 929      *         href="../util/Formatter.html#syntax">Format string syntax</a>.
 930      *
 931      * @param  args
 932      *         Arguments referenced by the format specifiers in the format
 933      *         string.  If there are more arguments than format specifiers, the
 934      *         extra arguments are ignored.  The number of arguments is
 935      *         variable and may be zero.  The maximum number of arguments is
 936      *         limited by the maximum dimension of a Java array as defined by
 937      *         <cite>The Java&trade; Virtual Machine Specification</cite>.
 938      *         The behaviour on a
 939      *         <tt>null</tt> argument depends on the <a
 940      *         href="../util/Formatter.html#syntax">conversion</a>.
 941      *
 942      * @throws  IllegalFormatException
 943      *          If a format string contains an illegal syntax, a format
 944      *          specifier that is incompatible with the given arguments,
 945      *          insufficient arguments given the format string, or other
 946      *          illegal conditions.  For specification of all possible
 947      *          formatting errors, see the <a
 948      *          href="../util/Formatter.html#detail">Details</a> section of the
 949      *          formatter class specification.
 950      *
 951      * @throws  NullPointerException
 952      *          If the <tt>format</tt> is <tt>null</tt>
 953      *
 954      * @return  This writer
 955      *
 956      * @since  1.5
 957      */
 958     public PrintWriter format(Locale l, String format, Object ... args) {
 959         try {
 960             synchronized (lock) {
 961                 ensureOpen();
 962                 if ((formatter == null) || (formatter.locale() != l))




 767      * args)</tt> behaves in exactly the same way as the invocation
 768      *
 769      * <pre>
 770      *     out.format(format, args) </pre>
 771      *
 772      * @param  format
 773      *         A format string as described in <a
 774      *         href="../util/Formatter.html#syntax">Format string syntax</a>.
 775      *
 776      * @param  args
 777      *         Arguments referenced by the format specifiers in the format
 778      *         string.  If there are more arguments than format specifiers, the
 779      *         extra arguments are ignored.  The number of arguments is
 780      *         variable and may be zero.  The maximum number of arguments is
 781      *         limited by the maximum dimension of a Java array as defined by
 782      *         <cite>The Java&trade; Virtual Machine Specification</cite>.
 783      *         The behaviour on a
 784      *         <tt>null</tt> argument depends on the <a
 785      *         href="../util/Formatter.html#syntax">conversion</a>.
 786      *
 787      * @throws  java.util.IllegalFormatException
 788      *          If a format string contains an illegal syntax, a format
 789      *          specifier that is incompatible with the given arguments,
 790      *          insufficient arguments given the format string, or other
 791      *          illegal conditions.  For specification of all possible
 792      *          formatting errors, see the <a
 793      *          href="../util/Formatter.html#detail">Details</a> section of the
 794      *          formatter class specification.
 795      *
 796      * @throws  NullPointerException
 797      *          If the <tt>format</tt> is <tt>null</tt>
 798      *
 799      * @return  This writer
 800      *
 801      * @since  1.5
 802      */
 803     public PrintWriter printf(String format, Object ... args) {
 804         return format(format, args);
 805     }
 806 
 807     /**


 818      * @param  l
 819      *         The {@linkplain java.util.Locale locale} to apply during
 820      *         formatting.  If <tt>l</tt> is <tt>null</tt> then no localization
 821      *         is applied.
 822      *
 823      * @param  format
 824      *         A format string as described in <a
 825      *         href="../util/Formatter.html#syntax">Format string syntax</a>.
 826      *
 827      * @param  args
 828      *         Arguments referenced by the format specifiers in the format
 829      *         string.  If there are more arguments than format specifiers, the
 830      *         extra arguments are ignored.  The number of arguments is
 831      *         variable and may be zero.  The maximum number of arguments is
 832      *         limited by the maximum dimension of a Java array as defined by
 833      *         <cite>The Java&trade; Virtual Machine Specification</cite>.
 834      *         The behaviour on a
 835      *         <tt>null</tt> argument depends on the <a
 836      *         href="../util/Formatter.html#syntax">conversion</a>.
 837      *
 838      * @throws  java.util.IllegalFormatException
 839      *          If a format string contains an illegal syntax, a format
 840      *          specifier that is incompatible with the given arguments,
 841      *          insufficient arguments given the format string, or other
 842      *          illegal conditions.  For specification of all possible
 843      *          formatting errors, see the <a
 844      *          href="../util/Formatter.html#detail">Details</a> section of the
 845      *          formatter class specification.
 846      *
 847      * @throws  NullPointerException
 848      *          If the <tt>format</tt> is <tt>null</tt>
 849      *
 850      * @return  This writer
 851      *
 852      * @since  1.5
 853      */
 854     public PrintWriter printf(Locale l, String format, Object ... args) {
 855         return format(l, format, args);
 856     }
 857 
 858     /**


 862      *
 863      * <p> The locale always used is the one returned by {@link
 864      * java.util.Locale#getDefault() Locale.getDefault()}, regardless of any
 865      * previous invocations of other formatting methods on this object.
 866      *
 867      * @param  format
 868      *         A format string as described in <a
 869      *         href="../util/Formatter.html#syntax">Format string syntax</a>.
 870      *
 871      * @param  args
 872      *         Arguments referenced by the format specifiers in the format
 873      *         string.  If there are more arguments than format specifiers, the
 874      *         extra arguments are ignored.  The number of arguments is
 875      *         variable and may be zero.  The maximum number of arguments is
 876      *         limited by the maximum dimension of a Java array as defined by
 877      *         <cite>The Java&trade; Virtual Machine Specification</cite>.
 878      *         The behaviour on a
 879      *         <tt>null</tt> argument depends on the <a
 880      *         href="../util/Formatter.html#syntax">conversion</a>.
 881      *
 882      * @throws  java.util.IllegalFormatException
 883      *          If a format string contains an illegal syntax, a format
 884      *          specifier that is incompatible with the given arguments,
 885      *          insufficient arguments given the format string, or other
 886      *          illegal conditions.  For specification of all possible
 887      *          formatting errors, see the <a
 888      *          href="../util/Formatter.html#detail">Details</a> section of the
 889      *          Formatter class specification.
 890      *
 891      * @throws  NullPointerException
 892      *          If the <tt>format</tt> is <tt>null</tt>
 893      *
 894      * @return  This writer
 895      *
 896      * @since  1.5
 897      */
 898     public PrintWriter format(String format, Object ... args) {
 899         try {
 900             synchronized (lock) {
 901                 ensureOpen();
 902                 if ((formatter == null)


 922      * @param  l
 923      *         The {@linkplain java.util.Locale locale} to apply during
 924      *         formatting.  If <tt>l</tt> is <tt>null</tt> then no localization
 925      *         is applied.
 926      *
 927      * @param  format
 928      *         A format string as described in <a
 929      *         href="../util/Formatter.html#syntax">Format string syntax</a>.
 930      *
 931      * @param  args
 932      *         Arguments referenced by the format specifiers in the format
 933      *         string.  If there are more arguments than format specifiers, the
 934      *         extra arguments are ignored.  The number of arguments is
 935      *         variable and may be zero.  The maximum number of arguments is
 936      *         limited by the maximum dimension of a Java array as defined by
 937      *         <cite>The Java&trade; Virtual Machine Specification</cite>.
 938      *         The behaviour on a
 939      *         <tt>null</tt> argument depends on the <a
 940      *         href="../util/Formatter.html#syntax">conversion</a>.
 941      *
 942      * @throws  java.util.IllegalFormatException
 943      *          If a format string contains an illegal syntax, a format
 944      *          specifier that is incompatible with the given arguments,
 945      *          insufficient arguments given the format string, or other
 946      *          illegal conditions.  For specification of all possible
 947      *          formatting errors, see the <a
 948      *          href="../util/Formatter.html#detail">Details</a> section of the
 949      *          formatter class specification.
 950      *
 951      * @throws  NullPointerException
 952      *          If the <tt>format</tt> is <tt>null</tt>
 953      *
 954      * @return  This writer
 955      *
 956      * @since  1.5
 957      */
 958     public PrintWriter format(Locale l, String format, Object ... args) {
 959         try {
 960             synchronized (lock) {
 961                 ensureOpen();
 962                 if ((formatter == null) || (formatter.locale() != l))