Writer sınıfı

advertisement
Writer sınıfı
java.lang.Object
java.io.Writer
•
java.lang.Object
•
o
•
java.io.Writer
All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable
Direct Known Subclasses:
BufferedWriter, CharArrayWriter,
PrintWriter, StringWriter
FilterWriter,
OutputStreamWriter,
PipedWriter,
public abstract class Writer
extends Object
implements Appendable, Closeable, Flushable
Abstract class for writing to character streams. The only methods that a subclass must
implement are write(char[], int, int), flush(), and close(). Most subclasses, however, will
override some of the methods defined here in order to provide higher efficiency, additional
functionality, or both.
Since:
JDK1.1
See Also:
Writer, BufferedWriter, CharArrayWriter, FilterWriter, OutputStreamWriter,
FileWriter, PipedWriter, PrintWriter, StringWriter, Reader
•
Veri alanı:
protected Object lock
Akımı eşzamanlı kılmak için kullanılan nesne.
Java.io.Writer sınıfının kurucuları
protected
Writer()
Karekter çıkış akımı yaratır. Kritik bölümleri kendisi ile eşzamanlı olur.
protected
Writer(Object lock)
Karekter çıkış akımı yaratır. Kritik bölümleri parametrede verilen Object ile eşzamanlı olur.
Java.io.Writer sınıfının metotları
append(char c)
Appends the specified character to this writer.
Writer
append(CharSequence csq)
Appends the specified character sequence to this writer.
Writer
append(CharSequence csq, int start, int end)
Appends a subsequence of the specified character sequence to this writer.
abstract void
close()
Closes the stream, flushing it first.
abstract void
flush()
Flushes the stream.
void
write(char[] cbuf)
Writes an array of characters.
abstract void
write(char[] cbuf, int off, int len)
Writes a portion of an array of characters.
void
write(int c)
Writes a single character.
void
write(String str)
Writes a string.
void
write(String str, int off, int len)
Writes a portion of a string.
java.lang.Object sınıfından kalıtsal gelen metotlar
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait,
wait
Writer Sınıfının Metotları
Writer
append(char c)
Appends the specified character to this writer.
Writer
append(CharSequence csq)
Appends the specified character sequence to this writer.
Writer
append(CharSequence csq, int start, int end)
Appends a subsequence of the specified character sequence to this writer.
close()
Close the stream, flushing it first.
abstract
void
abstract
void
flush()
Flush the stream.
write(char[] cbuf)
Write an array of characters.
void
write(char[] cbuf, int off, int len)
Write a portion of an array of characters.
abstract
void
write(int c)
Write a single character.
void
write(String str)
Write a string.
void
write(String str, int off, int len)
Write a portion of a string.
void
Program 8. write() metodu ile yazma
// Demonstrate System.out.write().
class WriteDemo {
public static void main(String args[]) {
int b;
b = 'A';
System.out.write(b);
System.out.write('\n');
}
}
/*
public void write(int b)
Write the specified byte to this stream. If the byte is a newline and automatic flushing
is enabled then the flush method will be invoked.
*/
Program 9. PrintWriter ile yazma
// PrintWriter ile yazma
import java.io.*;
public class PrintWriterDemo {
public static void main(String args[]) {
PrintWriter pw = new PrintWriter(System.out, true);
pw.println("Ankara başkenttir.");
int i = -7;
pw.println(i);
double d = 4.5e-7;
pw.println(d);
}
}
Program: write() metodu ile yazma
// Demonstrate System.out.write().
class WriteDemo {
public static void main(String args[]) {
int b;
b = 'A';
System.out.write(b);
System.out.write('\n');
}
}
/*
public void write(int b)
Write the specified byte to this stream. If the byte is a newline and automatic flushing is enabled then
the flush method will be invoked.
*/
Program: PrintWriter ile yazma
// PrintWriter ile yazma
import java.io.*;
public class PrintWriterDemo {
public static void main(String args[]) {
PrintWriter pw = new PrintWriter(System.out, true);
pw.println("Ankara başkenttir.");
int i = -7;
pw.println(i);
double d = 4.5e-7;
pw.println(d);
}
}
Download
Random flashcards
Merhaba

2 Cards oauth2_google_861773e1-0890-4522-834a-6a5babb58e76

En Mimar Architecture LTD ŞTİ XD

2 Cards asilyasar069

321işletme

2 Cards oldcity

KALPTE İLETİM NOKTALARI

3 Cards oauth2_google_cfd2531f-f18a-45fd-9d97-afe31596ce7b

Create flashcards