fdsa


J. F.
Diese Karteikarten bieten einen umfassenden Überblick über die Java-Programmierung, insbesondere zu Themen wie Dateiverarbeitung, Funktionen und Sammlungen. Sie decken wichtige Konzepte wie das Arbeiten mit Pfaden, Dateien und Strings ab, sowie das Verhalten von Sammlungen und deren Sortiermethoden. Die Karteikarten sind ideal für Entwickler, die ihr Wissen in Java vertiefen möchten, insbesondere in Bezug auf die Handhabung von Sammlungen, das Sortieren und Vergleichen von Objekten sowie die Verwendung von Stream-APIs und Collectors.
Karten
496
Lernende
3
Sprache
Deutsch
Kategorie
Informatik
Stufe
Andere
Erstellt / Aktualisiert
06.12.2020 / 24.01.2021

Lernkarten

Whats wrong here?: 

  1. new BufferedInputStream(new FileReader("z.txt"));
  2. new BufferedWriter(new FileOutpuitStream("z.txt"));
  3. new ObjectInputStream(new FileOutputStream("z.txt"));
  4. new BufferedInputStream(new InputStream());

  1. Mix reader/writer
  2. "
  3. Mix outputStream with InputStream
  4. InputStream is a abstract class

Whats the stream-class for  reading file data as bytes? Low/Highlvl?

FileInputStream  - low

Whats the stream-class for  writing file data as bytes? Low/Highlvl?

FileOutputStream - low

Whats the stream-class for  reading file data as characters? Low/Highlvl?

FileReader  -low

Whats the stream-class for  writing file data as characters? Low/Highlvl?

FileWriter - low

Whats the stream-class for  reading byte data from exsting InputStream in buffered manner? Low/Highlvl?

BufferedInputStream  - high

Whats the stream-class for writing byte data to an existing outputstream in a buffered manner? Low/Highlvl?

BufferedOutputStream  - High

Whats the stream-class for  reading character data from exsting Reader in a buffered manner? Low/Highlvl?

BufferedReader - high

Whats the stream-class for  writing character data to an existing writer in a buffered manner? Low/Highlvl?

BufferedWriter

Whats the stream-class for deserializing primitive java datay types and graphs of java objects from an existing InputStream ? Low/Highlvl?

ObjectInputStream - High

Whats the stream-class for  serializing primitive java data types and graphs of java objects to an existing outputstream? Low/Highlvl?

ObjectOutputStream  -  High

Whats the stream-class for  writing formatted representations of java objects to a binary stream? Low/Highlvl?

PrintStream - High

Whats the stream-class for  writing formatted representations of objects to a character stream? Low/Highlvl?

PrintWriter  - High

Does OutputStream/Writer.write and IntputStream/Reader.read() use byte-values?

No, ints: void write(int b);   int read() 
 

Whats the signature of InputStream/reader.read?

public int read() throws IOException

Whats the Sginature of OutputStream/writer.write()?

public void write(int b) throws IOException

How to check if an InputStream is at the end?

will return -1

What does offset 5, length 3 mean for a OutputStream?

should read up to 3 bytes and put them into the array stating with position 5

Are there read/write methods for Output/Input-stream/Reader/writer with offset and length?

Yes, overloaded, f.e.:
read(byte[] b, int offset, int length)
write(char[] c, int offset, int length)

How to close a IOStream?

public void close() throws IOException

Where should a stream which is passed around be closed?

In the method that created it

How to check if a stream supports mark()?

public boolean markSupported()

What dopes the readlimit mean in mark?

Instructs the stream that we expect to call reset() after at most x-bytes. if later: it may throws an exception, depending on the stream class

What does the returnparam of skip tells us?

How many values actuell got skipped

Whats the signature for  closing a stream and releasing resoruces ? For what stream class(es)?

void close()  - All streams

Whats the signature for   reading a single byte/return -1 if no bytes are availiable? For what stream class(es)?

int read()  -- all input-streams

Whats the signature for reading values into a buffer, returning the number of bytes read? For what stream class(es)?

int read(byte[] b) / int read(char[] c)    : InputStream / Reader

Whats the signature for   reading up to length values into a buffer starging from offset, returning number of bytes read? For what stream class(es)?

  • int read(byte[] b, int offset, int length)   - InputStream
  • int read(char[] c, int offset, int length)   - Reader

Whats the signature for writing a single byte? For what stream class(es)?

void write(int)    - all output streams

Whats the signature for   writing an array of values into the stream? For what stream class(es)?

  • void write(byte[] b)   - OutputStream
  • void write(char[] c)   - Writer

Whats the signature for writing length values from an array into the stream, starting with an offset index? For what stream class(es)?

  • void write(byte[] b, int offset, int length)     - OutputStream
  • void write(char[] c, int offset, int length)     - Writer

 

Whats the signature for returning true if the stream supports mark? For what stream class(es)?

boolean markSupported()  - All input streams

Whats the signature for  marking the current positin in the stream? For what stream class(es)?

mark(int readLimit)  - all input streams

Whats the signature for attempting to reset the stream to the mark() position? For what stream class(es)?

void reset()  - all inputstreams

Whats the signature for  reading and discarding a specified number of characters? For what stream class(es)?

long skip(long n)  - all input streams

Whats the signature for  flushing buffered data through the stream? For what stream class(es)?

void flush()  - all output streams

What are the constructors for FileInputStream?

  • public FileInputStream(File file) throws FileNotFoundException
  • public FileInputStream(String name) throws FileNotFoundException

What are the Constroucts for FileOutputStream?

  • public FileOutputStream(File file) throws FileNotFoundException
  • public FileOutputStream(String name) throws FileNotFoundException

What are the constructs of BufferedInputstream and BufferedOutputStream?

  • public BufferedInputStream(InputStream in)
  • public BufferedOutputStream(OutputStream out)

What are the Constructors of FileReader and FileWriter?

  • public FileReader(File file) throws FileNotFoundException
  • public FileReader(String name) throws FileNotFoundException
  • public FileWriter(File file) throws FileNotFoundException
  • public FileWriter(String name) throws FileNotFoundException

Lernen