Java
Is a programming language. See also Eclipse, EMF, JMonkeyEngine, Gradle.
- Loading an XML DOM Document from an InputStream or IFile
- Writing an XML DOM Document into an InputStream or IFile
- Traversing an XML DOM document and creating new elements
- An Abstract implementation of Dijkstra’s Algorithm in Java and a concrete implementation using EClass composition.
- Writing a String to a File in Java
- Reading and Writing Strings to Files in Java (reference)
- Out of Memory in Java
- A Memory-sensitive HashMap Cache for Java
- When Process.waitFor() hangs forever
- Runtime.exec returns -1073741515 when providing environment variables
- Debugging Java applications remotely with Eclipse
- Groovy
- Other pages tagged as “java”
private abstract static strictfp class X { public static final synchronized strictfp void x(Object[] e, List x) {
for (int i = 0; i < e.length; i++) if (e[i] instanceof IType || (showMembers && e[i] instanceof IMember &&
!(Flags.isPrivate(((IMember) e[i]).getFlags()) || Flags.isProtected(((IMember) e[i]).getFlags())))) x.add(e[i]); }
}
;D
Convert an int into a character (0-25 to a-z)
public char getchr(int c) {
byte[] b = new byte[] { (new Integer(c + 96)).byteValue() };
String s = new String(b);
return s.charAt(0);
}
Get MD5 Hash of a String
From http://site.gravatar.com/site/implement
import java.util.*;
import java.io.*;
import java.security.*;
public class MD5Util {
public static String hex(byte[] array) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length; ++i) {
sb.append(Integer.toHexString((array[i]
& 0xFF) | 0x100).substring(1,3));
}
return sb.toString();
}
public static String md5Hex (String message) {
try {
MessageDigest md =
MessageDigest.getInstance("MD5");
return hex (md.digest(message.getBytes("CP1252")));
} catch (NoSuchAlgorithmException e) {
} catch (UnsupportedEncodingException e) {
}
return null;
}
}
Writing to a File using an InputStream
/**
* Write an InputStream to a file. If the file exists, it will be
* overwritten.
*
* @param file the file to write to
* @param stream the input stream to read from
* @throws IOException if an IO exception occurs
*/
public static void writeFile(File file, InputStream stream) throws IOException {
FileOutputStream os = new FileOutputStream(file);
// write from an input stream
int bufSize = 128;
byte[] chars = new byte[bufSize];
int numRead = 0;
while ((numRead = stream.read(chars)) > -1) {
os.write(chars, 0, numRead);
}
os.close();
}
Change the Depth of JVM Stack Trace
This might be handy if you are running into too many (or too few) StackOverflowErrors. The -Xss
parameter defines the stack size for each thread, default -Xss512k
which means 512 KB.