Java Fundamental Tricks and Shortcuts

0
837
Java Programming

Small tidbits that can save you hours of trouble shooting in Java

How to Splitting on a “.” period you need to escape it

String [] yourArray = testString.split(“\\.”);
yourWord = yourArray[x];

How to Convert from Hex String to Decimal and then output a string

Integer.toString(Integer.parseInt(hexString, 16))

how to clear out a file without deleting the file, this is very useful to convert to a helper method if you manipulateĀ a ton of files

PrintWriter writer = new PrintWriter(file);
writer.print("");
writer.close();