Java.Streams.What do you know about the FileFilter interface?

📘 What is FileFilter?

  • It’s part of java.io.
  • It’s a functional interface with one method:
boolean accept(File pathname);

Used to filter files or directories based on your logic (e.g., extension, size, name pattern).

Continue reading →
Posted in Без рубрики | Comments Off on Java.Streams.What do you know about the FileFilter interface?

Java.Streams.What methods of the File class do you know?

Here’s a categorized list of the most commonly used methods of the File class:


📁 File Creation & Deletion

MethodDescription
createNewFile()Creates a new empty file if it doesn’t exist
delete()Deletes the file or directory
deleteOnExit()Deletes file when JVM exits
Continue reading →
Posted in Без рубрики | Comments Off on Java.Streams.What methods of the File class do you know?

Java.Which class is designed to work with file system elements?

📁 java.io.File


🧠 What is File?

  • It’s a class in the java.io package.
  • It represents a file or directory path in an abstract, platform-independent way.
  • It does not read/write file content itself — it provides metadata and file system operations.
Continue reading →
Posted in Без рубрики | Comments Off on Java.Which class is designed to work with file system elements?

Java.Streams.Why not use BufferedReader / BufferedWriter always ?

in most real-world scenarios, buffering improves performance and is recommended:

  • ✅ Reduces I/O system calls
  • ✅ Speeds up character-by-character reading/writing
  • ✅ Adds convenient methods: readLine(), newLine()

That’s why BufferedReader and BufferedWriter are used in 90%+ of text-processing code.

Continue reading →
Posted in Без рубрики | Comments Off on Java.Streams.Why not use BufferedReader / BufferedWriter always ?

Java.Streams.What classes allow you to speed up reading/writing by using a buffer?

🚀 Buffered I/O Classes in Java

🔹 1. BufferedInputStream

  • Extends: FilterInputStream
  • Buffers: Raw byte input
  • Used with: InputStream
InputStream in = new BufferedInputStream(new FileInputStream("file.bin"));
Continue reading →
Posted in Без рубрики | Comments Off on Java.Streams.What classes allow you to speed up reading/writing by using a buffer?

Java.Streams.What classes allow you to convert byte streams to character streams and back?

🔁 Classes that Convert Between Byte and Character Streams

🔹 1. InputStreamReader

  • Converts: InputStream → Reader
  • Direction: Byte → Character
  • Use case: Reading a byte stream (e.g., from a file or network) as text.

✅ Example:

InputStream is = new FileInputStream("input.txt");
Reader reader = new InputStreamReader(is, "UTF-8");
  • Wraps an InputStream
  • Decodes bytes into characters using a charset (e.g., UTF-8)
Continue reading →
Posted in Без рубрики | Comments Off on Java.Streams.What classes allow you to convert byte streams to character streams and back?

Java.Streams.

🔄 Commonalities

FeatureInputStream / OutputStreamReader / Writer
Belong tojava.io packagejava.io package
Abstract classesYes ✅Yes ✅
Base for stream hierarchyYes ✅Yes ✅
Support chaining/wrappingYes ✅Yes ✅ (e.g., with buffering)
Need to be closedYes ✅ (implements Closeable)Yes ✅ (implements Closeable)
Support try-with-resourcesYes ✅Yes ✅

So all four are abstract base classes that handle I/O streams, support stream composition (via decorators like Buffered*), and must be explicitly closed (or auto-closed with try-with-resources).

Continue reading →
Posted in Без рубрики | Comments Off on Java.Streams.

Java.Streams.What is the difference between the PrintWriter class and the PrintStream?

🆚 PrintWriter vs PrintStream

FeaturePrintWriterPrintStream
Packagejava.iojava.io
ExtendsWriter (character-based)OutputStream (byte-based)
Works withCharacter streamsByte streams
Encoding-aware✅ Yes (especially with OutputStreamWriter)❌ No — uses platform default charset
Methodsprint(), println(), printf(), write()print(), println(), printf(), write()
Autoflush✅ Optional (with constructor flag)✅ Optional (with constructor flag)
Can suppress IOExceptions?✅ Yes (can check checkError())✅ Yes (can check checkError())
Better forText-based files, writers, UnicodeConsole output, logging, binary files
Example outputEncoded characters (using specified charset)Raw bytes with system encoding

Continue reading →
Posted in Без рубрики | Comments Off on Java.Streams.What is the difference between the PrintWriter class and the PrintStream?

Java.Streams.What subclasses of the Writer class do you know, what are they for?

📘 Writer Overview

  • Writer is an abstract class in java.io for writing character data.
  • It’s the counterpart to OutputStream, but designed for writing text (characters and strings) rather than raw bytes.
Continue reading →
Posted in Без рубрики | Comments Off on Java.Streams.What subclasses of the Writer class do you know, what are they for?

Java.Streams.What subclasses of the Reader class do you know, what are they for?

The Reader class is part of Java’s character-based I/O system, introduced to handle text data (as opposed to InputStream which handles raw bytes). Let’s go over the key subclasses and their purposes.

Continue reading →
Posted in Без рубрики | Comments Off on Java.Streams.What subclasses of the Reader class do you know, what are they for?