CodeGym
CodeGym University
Java FullStack
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
  • Permissions and access to the file system

    JAVA 25 SELF
    Level 38, Lesson 3
    In this lecture we examine how the OS manages access rights (POSIX and ACL on Windows), why Java throws AccessDeniedException, how and when to use checks Files.isReadable(), Files.isWritable(), Files.isExecutable(), and why TOCTOU is dangerous. We show the “safe write” pattern: a temporary file plus an atomic move via StandardCopyOption.ATOMIC_MOVE, proper error handling with try- catch, and logging ( java.util.logging). Finally, there are practical tips and common mistakes.
    Available
  • Best Practices for Working with Files

    JAVA 25 SELF
    Level 38, Lesson 4
    A practical guide to reliable and secure work with the file system in Java: proper exception handling ( try/ catch, targeted responses to IOException, AccessDeniedException), careful use of the Files/ Path APIs and backups ( Files.copy with StandardCopyOption.REPLACE_EXISTING), temporary files ( Files.createTempFile), integrity checks ( MessageDigest.getInstance( "SHA-256")), as well as minimizing TOCTOU windows and using try-with-resources everywhere. You will learn why an empty catch is dangerous, how to work with permissions ( File.canRead()/ File.canWrite()), and what pitfalls relative paths like File( "data.txt") entail.
    Available
  • NIO2: Files, Paths, Files.walk: file system traversal

    JAVA 25 SELF
    Level 39, Lesson 0
    An in-depth look at the file API NIO2: working with paths via Path and utilities in Files, traversing directory trees with Files.walk and the FileVisitor interface, filtering and search, size calculation and copying, try-with-resources, and handling IOException. We’ll compare it to the old File API and go through common mistakes when working with Stream<Path> streams.
    Available
  • File, Path, Files: getting file information

    JAVA 25 SELF
    Level 39, Lesson 1
    A concise and practical overview of the file I/O APIs: from the veteran File to modern Path and Files from the java.nio.file package. We’ll cover existence checks, type (file/directory), sizes, paths, basic attributes, and permissions. We’ll show when and why you should prefer Path/ Files, how to properly handle IOException, and which mistakes are most common in practice.
    Available
  • Globbing/PathMatcher, DirectoryStream.Filter

    JAVA 25 SELF
    Level 39, Lesson 2
    A practical lecture on selecting files in NIO2: we’ll compare glob and regex, learn to use PathMatcher, filter directory contents via Files.newDirectoryStream and DirectoryStream.Filter<Path>, as well as perform recursive search with Files.walk() and conditional selections with Files.find() and BiPredicate<Path, BasicFileAttributes>. We’ll discuss pattern nuances ( "**/*.java", "*.{png,jpg}"), performance, and common mistakes when closing resources.
    Available
  • FileVisitor — file system traversal and recursive operations

    JAVA 25 SELF
    Level 39, Lesson 3
    In this lecture, we’ll examine advanced file system traversal in Java: how a streamed traversal via Files.walk() differs from the event-driven API Files.walkFileTree(), how the FileVisitor<T> contract and the convenient adapter SimpleFileVisitor<T> work, what decisions FileVisitResult returns ( CONTINUE, SKIP_SUBTREE, SKIP_SIBLINGS, TERMINATE), how to correctly perform recursive deletion, size calculation, pattern-based search, and error handling, as well as which common mistakes occur in practice.
    Available
  • Getting and changing file attributes

    JAVA 25 SELF
    Level 39, Lesson 4
    A practical guide to working with file metadata via the java.nio.file.attribute API: read basic attributes with Files.readAttributes and BasicFileAttributes, dig into extended POSIX/ DOS attributes using PosixFileAttributes and DosFileAttributes, change timestamps and permissions ( FileTime, PosixFilePermissions, Files.setLastModifiedTime, Files.setAttribute). Plus access checks ( Files.isReadable/ isWritable/ isExecutable), cross‑platform nuances ( dos:* vs posix:*) and common pitfalls.
    Available
  • Creating and deleting files and folders

    JAVA 25 SELF
    Level 40, Lesson 0
    A practical introduction to Java’s file API: working with java.nio.file, creating files and directories via Files.createFile, Files.createDirectory and Files.createDirectories, deleting — using Files.delete and Files.deleteIfExists. We will discuss existence checks ( Files.exists, Path.of), common exceptions ( FileAlreadyExistsException, NoSuchFileException, DirectoryNotEmptyException, IOException) and safe deletion, including recursive deletion for non-empty directories.
    Available
  • Copying and moving files and folders

    JAVA 25 SELF
    Level 40, Lesson 1
    How to copy, move, and rename files and folders using Files.copy and Files.move from the java.nio.file package; which options to use ( StandardCopyOption.REPLACE_EXISTING, COPY_ATTRIBUTES, atomic move), how copy differs from move, and how to properly handle exceptions: FileAlreadyExistsException, AccessDeniedException, AtomicMoveNotSupportedException, NoSuchFileException. Plus practical tips and tables for the key methods and options.
    Available
  • Bulk file operations

    JAVA 25 SELF
    Level 40, Lesson 2
    Hands-on file processing with NIO.2: how to traverse directories with Files.list and Files.walk, filter streams of paths with Stream<Path> and the operations filter, sorted, limit. Bulk actions: copying ( Files.copy), deleting ( Files.delete), renaming ( Files.move) with safe error handling in a loop and performance considerations for recursive traversal. A table of key methods and a “Common mistakes” section will help you avoid pitfalls.
    Available
  • Working with temporary files and directories

    JAVA 25 SELF
    Level 40, Lesson 3
    In this lecture, we cover how to safely create and clean up temporary resources: files via Files.createTempFile and directories via Files.createTempDirectory, where they go by default and how to specify your own folder. We’ll show reliable deletion using Files.delete/ Files.deleteIfExists, when the legacy method File.deleteOnExit() is appropriate, how to get the path to the system temp folder via System.getProperty( "java.io.tmpdir"), and why it’s important to use try- finally for guaranteed cleanup. We’ll finish with practical tips and common pitfalls.
    Available
  • Monitoring file system changes: WatchService

    JAVA 25 SELF
    Level 40, Lesson 4
    In the lecture we cover the NIO.2 file system watching API — WatchService: how to obtain the service, register a directory via Path.register(...), what events are available ( ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY), and how to organize the processing loop ( WatchService.take() → key.pollEvents() → key.reset()). We’ll discuss limitations (no recursive watching by default), specifics on Windows/Linux/macOS, real-world examples, and common mistakes.
    Available
  • 1
  • ...
  • 17
  • 18
  • 19
  • 20
  • 21
  • ...
  • 30
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