Various methods for reading the contents of a file from disk into a string.
One-liner bonus! 😄
String contents = new String(Files.readAllBytes(Paths.get(fileName)));
#!/bin/bash | |
# http://commons.apache.org/proper/commons-exec/commandline.html | |
# http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_07.html | |
while [ $# -gt 0 ] | |
do | |
echo "$1" | |
shift | |
done |
import java.io.*; | |
/** | |
* @see <a href="http://alvinalexander.com/java/edu/pj/pj010016">Running system commands in Java applications</a> | |
* / | |
public class JavaRunCommand { | |
public static void main(String args[]) { | |
String s = null; |
#! /bin/sh | |
# ================================================================== | |
# ______ __ _____ | |
# /_ __/___ ____ ___ _________ _/ /_ /__ / | |
# / / / __ \/ __ `__ \/ ___/ __ `/ __/ / / | |
# / / / /_/ / / / / / / /__/ /_/ / /_ / / | |
#/_/ \____/_/ /_/ /_/\___/\__,_/\__/ /_/ | |
# Multi-instance Apache Tomcat installation with a focus | |
# on best-practices as defined by Apache, SpringSource, and MuleSoft |
package org.gkh; | |
import java.io.BufferedReader; | |
import java.io.Console; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
public class ConsoleUtil { | |
/** |
/** | |
* Represents the Microsoft Azure AD service. The methods to which you should | |
* pay attention are {@link #executeJSONChunkRequest(JSONObject, String, int)} | |
* and {@link #setConfigData(String, int, String, JSONObject)}. These are | |
* respectively where data requests from <code>DaaS</code> come and where the | |
* service is configured. | |
* <p> | |
* This is the class referenced by collector templates. E.g. | |
* | |
* <pre> |
This is my attempt to capture some of the things I (relatively) frequently do in Markdown. It is by no means definitive, but I always seem to forget these ones.
Inline-style links use parentheses immediately after the link text. For example:
This is an [example link](http://example.com/).
There is a really good exchange on Programmers Stack Exchange on the number of assertions to have in a single unit test: Is it OK to have multiple asserts in a single unit test?
Proper unit tests should fail for exactly one reason, that's why you should be using one assert per unit test.
The "match at least one" example below relies on Hamcrest matchers. There is an alternative to Hamcrest, see AssertJ documentation.
# Download and unarchive Java | |
RUN mkdir /opt && curl -jksSLH "Cookie: oraclelicense=accept-securebackup-cookie"\ | |
http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz \ | |
| tar -xzf - -C /opt &&\ | |
ln -s /opt/jdk1.7.0_79 /opt/jdk &&\ | |
rm -rf /opt/jdk/*src.zip \ | |
/opt/jdk/lib/missioncontrol \ | |
/opt/jdk/lib/visualvm \ | |
/opt/jdk/lib/*javafx* \ | |
/opt/jdk/jre/lib/plugin.jar \ |
This article illustrates a quick start to using Log4J and commons logging. Obtaining a log factory and logging to various levels is fairly straight-forward. What can be tricky is getting the properties files correct. The code snippet below depends on:
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;