CodeGym
AI Academy
Promotion
CodeGym University
Learning
Courses
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme

Lessons

  • Reviews
  • About us
Start
Start learning
Start learning now
  • My Progress
  • Courses
  • University
  • Quest Map
  • Lessons
  • How to think in bytes, and why you need ByteArray

    Kotlin SELF
    Level 43, Lesson 0
    A lecture about a “mindset shift” in I/O: a file is first and foremost bytes, and text is only an interpretation. We’ll break down when readText() is not suitable and why binary data needs ByteArray, how the Byte type works (range - 128 .. 127), why you need a buffer, and why arrays are compared via contentEquals rather than the == operator. Plus, a bridge between the worlds of String and bytes via encodeToByteArray()/ decodeToString().
    Available
  • Working with bytes: readBytes() / writeBytes()

    Kotlin SELF
    Level 43, Lesson 1
    We’ll go through the shortest path of “read file → write file” for binary data in Kotlin/JVM: the extension functions File.readBytes() and File.writeBytes(bytes), working with the ByteArray type, validating the result via size ( length()) and byte-by-byte comparison ( contentEquals()), as well as the limitations of the “read everything” approach and typical mistakes (for example, comparing arrays via == and reading a binary file as text).
    Available
  • File streams: FileInputStream/FileOutputStream, EOF, and use

    Kotlin SELF
    Level 43, Lesson 2
    We break down low-level file work on the JVM through byte streams: how to read and write data using FileInputStream/ FileOutputStream, why InputStream.read() returns Int and what -1 (EOF) means, how to correctly connect the result of read(buffer) with write(buffer, 0, n), and why use {} is a mandatory habit for closing resources.
    Available
  • Buffering and chunk copying

    Kotlin SELF
    Level 43, Lesson 3
    We break down why copying “byte by byte” via read()/ write() is usually slow, how “our” buffer ByteArray differs from the wrappers BufferedInputStream/ BufferedOutputStream, what the contract of read(buffer) is (the value n and -1 at EOF), and what the canonical chunk-copy loop with output.write(buffer, 0, n) looks like. At the end: choosing a buffer size, a data-flow diagram (mermaid), and common mistakes.
    Available
  • ZIP archives: ZipEntry, reading/writing

    Kotlin SELF
    Level 43, Lesson 4
    We break down ZIP on the JVM as a streaming “container” of entries: what ZipEntry stores (primarily name and the directory flag), how to correctly write an archive via ZipOutputStream ( putNextEntry() → write bytes → closeEntry()), how to read via ZipInputStream (iterate nextEntry) and safely extract while defending against paths like ../../secret.txt. At the end — a mini CLI and common mistakes.
    Available
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning, and a Java developer’s career.
Follow us
Interface language
English
Deutsch Español हिन्दी Français Português Polski বাংলা 简体中文 मराठी தமிழ் Italiano Bahasa Indonesia 繁體中文 Nederlands 日本語 한국어 Bulgarian Danish Hungarian Basa Jawa Malay Norwegian Romanian Swedish Telugu Thai Українська Filipino Turkish Azərbaycan Русский Vietnamese
Programmers Are Made, Not Born © 2026 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2026 CodeGym