JavaRush
AI Academy
new
Promotion
Learning
Courses
Tasks
Quizzes
Games
Help
Schedule of nudges
Internship
Community
Users
Forum
Chat
Articles
Success stories
Activities
Reviews
Subscriptions
Light theme

Lectures

  • Reviews
  • About us
  • CS50
Start
Start learning
Start learning
  • My progress
  • Courses
  • Quest map
  • Lectures
  • I/O errors: IOException and FileNotFoundException

    Kotlin SELF
    45 level,0 lecture
    We break down why file operations on the JVM “break”, why checking exists() does not guarantee success, how the “umbrella” IOException differs from FileNotFoundException, how to structure try/ catch correctly (from specific to general), and what to print for diagnostics (operation, path, and the properties exists/ isFile/ isDirectory) so you do not turn debugging into guesswork.
    Open
  • Pre-checks before reading and writing: existence, type, permissions, directories

    Kotlin SELF
    45 level,1 lecture
    We cover practical file pre-checks in Kotlin/JVM: how to make sure a path exists, that it is actually a file, and that it is readable before reading ( exists(), isFile, canRead()), and how to prepare the parent directory before writing using parentFile and mkdirs(). Separately: quick path diagnostics and common mistakes (checking only exists(), ignoring the mkdirs() result, the illusion of guarantees from canWrite()).
    Open
  • try/catch around file operations

    Kotlin SELF
    45 level,2 lecture
    We break down why, for file operations in Kotlin, you can’t rely only on checks like exists() and why you still need try/ catch around real I/O. We learn to make a “narrow” try around readText()/ writeText(), use try as an expression, choose a function contract ( T?, Boolean, or rethrowing IOException), write useful error messages, order multiple catch blocks correctly, and close resources via use {}.
    Open
  • Atomic write: temp file + renameTo as protection against partial writes

    Kotlin SELF
    45 level,3 lecture
    We break down a practical “atomic write” protocol for saving important data to a file: why a direct call to writeText() during overwrite can leave a “truncated stub” on failure, how to write the new version to a temp file next to the target and then “publish” the result via renameTo(). We will assemble a function atomicWriteText with try/ finally, discuss the trade-offs of deleting the target, and typical mistakes (temp not next to the target, not checking the renameTo result, catching everything, etc.).
    Open
  • Backup and rotation: keep previous versions before replacing a file

    Kotlin SELF
    45 level,4 lecture
    We break down why you need a backup on top of atomic write, how to make the simplest .bak copy before replacing a file, why rotating copies should be done “from the end”, and how to assemble a safe save protocol: rotateBackups → atomicWriteText. At the end — a process diagram in mermaid and an analysis of typical mistakes (order of actions, ignoring renameTo, infinite copies).
    Open
Learn
  • Registration
  • Java course
  • Help with tasks
  • Pricing
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success stories
  • Activities
Company
  • About us
  • Contacts
  • Reviews
  • FAQ
  • Support
JavaRushJavaRush — is an interactive online course for learning Java programming from scratch. It contains 1200 practical tasks with one-click solution checking, the necessary minimum of theory on Java basics, and motivating features that help you complete the course: games, quizzes, interesting projects and articles on effective learning and the career of a Java developer.
Follow us
Язык интерфейса
Русский
English
Українська
"Programmers are not born" © 2026 JavaRush
MastercardVisa
"Programmers are not born" © 2026 JavaRush