JAVA 8 / NOTES</>↗Java 808 Jan 2024
The Stream.generate() method in Java is used to create an infinite stream of data, typically used when the programmer needs a limitless supply of data to be processed. Here’s an example of how you might use Stream.generate(): package org.kodejava.util; import java.util.stream.Stream; public class StreamGenerate { public static void main(String[] args) { Stream<String> stringStream = Stream.generate(() […]
JAVA 8 / NOTES</>↗Java 808 Jan 2024
Pattern.splitAsStream() in Java is a method that allows us to split a string into a stream of substrings given a regex pattern. This can be useful when we’re working with large strings, and we want to process the substrings in a functional style using Java Streams. Here’s a basic example of how you can use […]
IO / NOTES</>↗IO08 Jan 2024
The Files.walk() method in Java is a handy method when it comes to reading directory contents. Files.walk() method returns a Stream object that you can use to process each of the elements (files or directories) in the directory structure. This method walks the file tree in a depth-first manner, starting from the given path that […]
CORE API / NOTES</>↗Core API08 Jan 2024
In Java, you can use the Files.list() method to list all files in a given directory. Files.list(Path dir) is a method in the java.nio.file.Files class. This method returns a Stream that is lazily populated with Path by walking the directory tree rooted at a given starting file. The file tree is traversed depth-first, the elements […]
CORE API / NOTES</>↗Core API08 Jan 2024
The BufferedReader.lines() method is a Java 8 method that returns a Stream, each element of which is a line read from the BufferedReader. This allows you to perform operations on each line with Java’s functional programming methods. Returning a Stream of strings makes the BufferedReader.lines() method very efficient in terms of memory usage when working […]
JAVA 8 / NOTES</>↗Java 807 Jan 2024
The Java Stream API is a powerful tool introduced in Java 8. It is designed to process data in a declarative way. More specifically, it makes it easy to process sequences of data elements, such as collections or arrays. Here are some key points about Java Stream API: Non-mutating: Operations on streams do not mutate […]