What are some things in the class library you wish more people knew about or used?

3 years ago by JackbyDev to c/java

module index

I'm curious if there are things in the standard class library that you find useful but not widely used.

load all comments
grossjonas 8 points 3 years ago

PushbackInputStream - makes it easy to write a small template engine in restricted environments

path: 0 324085, hotness: undefined, score: 8, children: 2
JackbyDev 3 points 3 years ago

Link for the curious

A PushbackInputStream adds functionality to another input stream, namely the ability to "push back" or "unread" bytes, by storing pushed-back bytes in an internal buffer. This is useful in situations where it is convenient for a fragment of code to read an indefinite number of data bytes that are delimited by a particular byte value; after reading the terminating byte, the code fragment can "unread" it, so that the next read operation on the input stream will reread the byte that was pushed back. For example, bytes representing the characters constituting an identifier might be terminated by a byte representing an operator character; a method whose job is to read just an identifier can read until it sees the operator and then push the operator back to be re-read.

This does sound useful. I have to admit I don't know much about InputStream and OutputStream and every time I need to do something with them (which is rare) I just search it up.

path: 0 324085 384465, hotness: undefined, score: 3, children: 0
pohart 1 point 3 years ago

Ooh, I've never seen that before. And it's been there since 1.0

path: 0 324085 330356, hotness: undefined, score: 1, children: 0
java
java

@programming.dev

login for more options
2059
259
9

For discussing Java, the JVM, languages that run on the JVM, and other related technologies.

go to feed...