edit this page - page history - about editing

Java

Is a programming language. See also Eclipse, EMF, JMonkeyEngine.
  1. Loading an XML DOM Document from an InputStream or IFile
  2. Writing an XML DOM Document into an InputStream or IFile
  3. Traversing an XML DOM document and creating new elements
  4. An Abstract implementation of Dijkstra's Algorithm in Java and a concrete implementation using EClass composition.
  5. Writing a String to a File in Java
  6. Reading and Writing Strings to Files in Java (reference)
  7. Out of Memory in Java
  8. A Memory-sensitive HashMap Cache for Java
  9. When Process.waitFor() hangs forever
  10. Runtime.exec returns -1073741515 when providing environment variables
  11. Debugging Java applications remotely with Eclipse
  12. 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]); } 
}
Mr. Green

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.
edit this page - what links to here? - page history - top
Last edited by jevon jevon 53 months ago