المزيد من الطرق:
- PrintStream printf(اللغة المحلية لكائن تنسيق السلسلة...الوسائط): طريقة ملائمة لكتابة سلسلة منسقة إلى دفق الإخراج هذا باستخدام سلسلة التنسيق المحددة والوسائط.
Syntax : public PrintStream printf(Locale l
Java
String format
Object... args)
Parameters:
l - The locale to apply during formatting. If l is null then no localization is applied.
format - A format string as described in Format string syntax
args - Arguments referenced by the format specifiers in the format string.
Returns:
This output stream
Throws:
IllegalFormatException
NullPointerException//Java program to demonstrate printf method import java.io.*; import java.util.Locale; class PrintStreamDemo { public static void main(String[] args) { String s = 'for'; // create printstream object PrintStream printStream = new PrintStream(System.out); // illustrating printf(Locale l String format Object... args) method printStream.printf(Locale.US 'Geeks%sGeeks' s); } }
Output:
GeeksforGeeks - PrintStream printf(كائن تنسيق السلسلة...الوسائط): طريقة ملائمة لكتابة سلسلة منسقة إلى دفق الإخراج هذا باستخدام سلسلة التنسيق المحددة والوسائط.
Syntax : public PrintStream printf(String format
Java
Object... args)
Parameters:
format - A format string as described in Format string syntax
args - Arguments referenced by the format specifiers in the format string.
Returns:
This output stream
Throws:
IllegalFormatException
NullPointerException//Java program to demonstrate printf(String format Object... args) method import java.io.*; public class PrintStreamDemo { public static void main(String[] args) { String s = 'for'; // create printstream object PrintStream obj= new PrintStream(System.out); // illustrating printf(String format Object... args) method obj.printf('Geeks%sGeeks' s); } }
Output:
GeeksforGeeks - طباعة باطلة (): ينهي السطر الحالي عن طريق كتابة سلسلة فاصل الأسطر.
Syntax : public void println()Java//Java program to demonstrate println() methods import java.io.PrintStream; class PrintStreamDemo { public static void main(String[] args) { PrintStream obj = new PrintStream(System.out); //illustrating println(); obj.println('GeeksforGeeks'); } }
Output:
GeeksforGeeks - طباعة باطلة (منطقية x): يطبع قيمة منطقية ثم ينهي السطر.
Syntax : public void println(boolean x)Java//Java program to demonstrate println(boolean) method import java.io.*; class PrintStreamDemo { public static void main(String[] args) { // create printstream object PrintStream obj = new PrintStream(System.out); //illustrating println(boolean) method obj.println(true); // flush the stream obj.flush(); } }
Output:
true - طباعة باطلة (شار x): يطبع حرفًا ثم ينهي السطر.
Syntax : public void println(char x)Java//Java program to demonstrate println(char x) method import java.io.*; public class PrintStreamDemo { public static void main(String[] args) { char c = 'g'; // create printstream object PrintStream obj = new PrintStream(System.out); // illustrating println(char x) obj.println(c); // flush the stream obj.flush(); } }
Output:
g - طباعة باطلة (شار [] س): طباعة مجموعة من الأحرف ثم إنهاء السطر.
Syntax : public void println(char[] x)Java//Java program to demonstrate println(char[] x) method import java.io.*; public class PrintStreamDemo { public static void main(String[] args) { char[] c = {'G' 'E' 'E''K'}; // create printstream object PrintStream obj = new PrintStream(System.out); // illustrating println(char[] x) obj.println(c); // flush the stream obj.flush(); } }
Output:
GEEK - طباعة باطلة (× مزدوج): يطبع مزدوجًا ثم ينهي السطر.
Syntax : public void println(double x)Javaالإخراج://Java program to demonstrate println(double x) method import java.io.*; public class PrintStreamDemo { public static void main(String[] args) { double c = 5.42762; // create printstream object PrintStream obj = new PrintStream(System.out); // illustrating println(double x) obj.println(c); // flush the stream obj.flush(); } }
5.42762 - طباعة باطلة (تعويم x): يطبع تعويمًا ثم ينهي السطر.
Syntax : public void println(float x)Javaالإخراج://Java program to demonstrate println(float x) method import java.io.*; public class PrintStreamDemo { public static void main(String[] args) { float c = 5.168502f; // create printstream object PrintStream obj = new PrintStream(System.out); // illustrating println(float x) obj.println(c); // flush the stream obj.flush(); } }
5.168502f - طباعة باطلة (int x): يطبع عددًا صحيحًا ثم ينهي السطر.
Syntax : public void println(boolean x)Javaالإخراج://Java program to demonstrate println(int x) method import java.io.*; public class PrintStreamDemo { public static void main(String[] args) { int c = 5; // create printstream object PrintStream obj = new PrintStream(System.out); // illustrating println(int x) obj.println(c); // flush the stream obj.flush(); } }
5
- طباعة باطلة (طويلة x): يطبع خطًا طويلًا ثم ينهي السطر.
Syntax : public void println(long x)Javaالإخراج://Java program to demonstrate println(long x) method import java.io.*; public class PrintStreamDemo { public static void main(String[] args) { long c = 123456789l; try { // create printstream object PrintStream obj= new PrintStream(System.out); // illustrating println(long x) obj.println(c); // flush the stream obj.flush(); } catch (Exception ex) { ex.printStackTrace(); } } }
123456789 - طباعة باطلة (الكائن x): يطبع كائنًا ثم ينهي السطر.
Syntax : public void println(Object x)Javaالإخراج://Java program to demonstrate println(Object x) method import java.io.*; public class PrintStreamDemo { public static void main(String[] args) { // create printstream object PrintStream obj = new PrintStream(System.out); //illustrating println(Object X) obj.println(obj); // flush the stream obj.flush(); } }
java.io.PrintStream@15db9742 - طباعة باطلة (سلسلة x): يطبع سلسلة ثم ينهي السطر.
Syntax : public void println(boolean x)Javaالإخراج:import java.io.*; //Java program to demonstrate println(String x) method public class PrintStreamDemo { public static void main(String[] args) { String c = 'GeeksforGeeks'; // create printstream object PrintStream ps = new PrintStream(System.out); // illustrating println(String x) ps.println(c); // flush the stream ps.flush(); } }
GeeksforGeeks - مجموعة الأخطاء المحمية (): يضبط حالة الخطأ للتيار على القيمة true.
Syntax : public void println(String x)Javaالإخراج://Java program to demonstrate setError() method import java.io.*; public class PrintStreamDemo extends PrintStream { public PrintStreamDemo(OutputStream out) { super(out); } public static void main(String[] args) { byte c[] = {65 66 67 68 69 70 71}; // create printstream object PrintStreamDemo obj = new PrintStreamDemo(System.out); // illustrating write() method obj.write(c 1 3); // flush the stream obj.flush(); //illustrating setError() method obj.setError(); } }
BCD
- كتابة باطلة (بايت [] buf int off int len): يكتب بايتات لين من صفيف البايت المحدد بدءًا من الإزاحة إلى هذا الدفق.
Syntax : public void write(byte[] buf
Java
int off
int len)
Overrides:
write in class FilterOutputStream
Parameters:
buf - A byte array
off - Offset from which to start taking bytes
len - Number of bytes to writeالإخراج://Java program to demonstrate write(int b) method import java.io.*; public class PrintStreamDemo { public static void main(String[] args) { byte c = 65; // create printstream object PrintStream obj = new PrintStream(System.out); //illustrating write(int b) obj.write(c); // flush the stream obj.flush(); } }
BCD - الكتابة الفارغة (int ب): يكتب البايت المحدد لهذا الدفق.
Syntax : public void write(int b)
Java
Overrides:
write in class FilterOutputStream
Parameters:
b - The byte to be writtenالإخراج://Java program to demonstrate write(int b) method import java.io.*; public class PrintStreamDemo { public static void main(String[] args) { byte c = 65; // create printstream object PrintStream obj = new PrintStream(System.out); //illustrating write(int b) obj.write(c); // flush the stream obj.flush(); } }
A