Java Create New File: Files.createFile() and CREATE_NEW
Java create new file examples with Files.createFile(), parent folders, CREATE_NEW writes and permissions, and how to avoid overwriting existing files.
Java create new file examples with Files.createFile(), parent folders, CREATE_NEW writes and permissions, and how to avoid overwriting existing files.
FileChannel transferTo() and transferFrom() examples. Copy and merge files, send a file to a socket, save streams, and loop past the 2 GB per-call limit.
Java MappedByteBuffer guide. Map files with FileChannel.map(), read and write mapped memory, call force(), and map files over 2 GB with MemorySegment.
Java NIO channel tutorial for Java 25. Open FileChannel and SocketChannel, read and write with ByteBuffer, use non-blocking mode and scatter/gather I/O.
Java NIO buffer tutorial. Learn position, limit and capacity, flip(), clear(), compact(), mark(), slices, direct buffers and byte order with ByteBuffer.
Java IO vs NIO compared for Java 25. Streams vs buffers, blocking vs selectors, NIO.2 Files and Path, virtual threads, and a table of which API to use.
Learn the Java NIO Path API with Path.of(), getParent(), resolve(), relativize(), normalize() vs toRealPath(), and absolute vs canonical paths in Java 25.
Java NIO read file examples. Use Files.readString(), read small and large files with FileChannel and ByteBuffer, decode UTF-8 safely and map large files.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.