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.
Flashcards
496
Students
3
Language
German
Category
Computer Science
Level
Other
Created / Updated
06.12.2020 / 24.01.2021

Flashcards

How to retrieve the name of a file/directory with a File-Object?

String getName()

How to retrieve the parentDirectory of a File-Object? Whats if there is none?

String getParent()  -> null if no parent

How to check if a File-object is a directory?

boolean isDirectory()

How to check if a File-Object is a File?

boolean isFile();

how to return the number of milliseconds since the epoch when the file was last modified for a File-Object?

long lastModified()

How to return the length of a File-Object? What if the file doesnt exist?

long length()   -> 0L if not exists

How to retrieve a list of files within a directory with a Files-Object?

File[] listFiles()

How to create a directory with a File-Object?

boolean mkdir()

boolean mkdirs()

How to rename a file/directory with a File-Object?

boolean renameTo(File dest)

What is the benefit of a BufferedOutput-Stream?

Can write a large chunk of bytes at a time, reducing round-tips and improve perfomance

Which two sets of stream-classes are difined in the java.io.API? How does the names end?

  • Byte-streams that end in InputStream/OutputStream
  • Character streams that end in Reader/Writer

Are Reader/Writers still streams?

Yes, I/O Streams

What are advantages of using a characterstream even if byte streams can do everything?

They are specificially focused on managing character/stringdata -> no need to worry about the underlying characterencoding of the file

Does the class PrintReader exist compliant to PrintWriter?

No

Is there a InputStream class for PrintStream?

Npo

What are the four abstract parents of all Streams?

InputStream, OutputStream, Reader, Writer

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

Study