As a bit of warning, this is some old Java code, but if you want to create your own Java file utilities (utility methods), this code might help you get started:
recent posts related to java, jdbc, spring, etc.
I ended up not using this code, but if you wanted to see one way to use JSoup’s OutputSettings (Document.OutputSettings) class to set some parameters before calling
JSoup.clean, I hope this is helpful:
// tried some things to improve the html output val settings: OutputSettings = new OutputSettings settings.prettyPrint(true) //`true` is default settings.charset("UTF-8") settings.outline(true) //this is close to what i want, but too extreme settings.indentAmount(4) val cleanHtml: String = Jsoup.clean(html, "", wl, settings)
I can attest that this code works, it’s just not what I need at the moment.
Also, the code shown is written in Scala, but as you can see, it converts easily to Java.
Java FAQ: How large can a Java
Answer: The Java BigInteger Scaladoc states the following:
“BigInteger must support values in the range -2Integer.MAX_VALUE (exclusive) to +2Integer.MAX_VALUE (exclusive) and may support values outside of that range.”
BigInt wraps Java’s
BigInteger, so it will also have the same data range.
I haven’t read the article I’ve linked to yet, I’m just saving it here for future reading.
In this InfoQ Java in 2019 Predictions article, this line stood out the most: Java 9 and 10 saw virtually no deployment to production. Working alone I occasionally wonder what large companies are doing, and with these Java major version number releases coming every six months I was wondering how that was playing out.
I just read a short chapter in the book Effective Java, and realized I was doing something pretty dumb in my own code by always creating my own custom exceptions instead of using other exceptions already intended to be reused in the Java API.
As I was just reminded, Java’s
javap command doesn’t show private members by default. You have to use the
-p option of
javap to see private members.
I was just reminded of that when using the Scala REPL. Given this
Person class with a private constructor field named
class Person(private var name: String)
javap without the
-p option shows this:
As a brief note, here’s some source code that I used to create a
JMenuBar in a Java application. First, I defined some fields in my main class:
private static final KeyStroke fileOpenKeystroke = KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.META_MASK); private Action fileOpenAction; private JMenuBar menuBar;
Later in the same class I defined this method:
As a brief note to self, I use these Java
keytool commands to add/update the SSL certificate for accessing a website named alphavantage.co:
Summary: This page is a printf formatting cheat sheet. I originally created this cheat sheet for my own purposes, and then thought I would share it here.
A cool thing about the printf formatting syntax is that the specifiers you can use are very similar, if not identical, between several different languages, including C, C++, Java, Perl, Ruby, and others, so your knowledge is reusable, which is a good thing.