These are some tux tricks or tips from tux.
Luis Alfonso Vega Garcia <[email protected]>
jsppp is a jsp beautifier, formatter; once installed, create a run command as follows:
$JAVA_HOME/bin/java -classpath \
$JSPPP_HOME/lib/getopt-1.0.9.jar:$JSPPP_HOME/dist/lib/jsppp.jar\
net.sourceforge.jsppp.JSPPP $*
Assertion checking defaults to off at runtime, unfortunately. You should always turn them on.
JVM runtime option:
% java -enableassertions Program
% java -ea Program
=head2 serialize to/from file
To serialize (save the Queue state to a file) :
public static void main(String args[]) {
Queue theQueue;
theQueue = new Queue();
theQueue.put("element 1");
theQueue.put("element 2");
theQueue.put("element 3");
theQueue.put("element 4");
System.out.println(theQueue.toString());
// serialize the Queue
System.out.println("serializing theQueue");
try {
FileOutputStream fout = new FileOutputStream("thequeue.dat");
ObjectOutputStream oos = new ObjectOutputStream(fout);
oos.writeObject(theQueue);
oos.close();
}
catch (Exception e) { e.printStackTrace(); }
}
To unserialize (to load a previously saved Queue) :
public static void main(String args[]) {
Queue theQueue;
theQueue = new Queue();
// unserialize the Queue
System.out.println("unserializing theQueue");
try {
FileInputStream fin = new FileInputStream("thequeue.dat");
ObjectInputStream ois = new ObjectInputStream(fin);
theQueue = (Queue) ois.readObject();
ois.close();
}
catch (Exception e) { e.printStackTrace(); }
System.out.println(theQueue.toString());
}
long start = System.currentTimeMillis();
expensiveTask();
long end = System.currentTimeMillis();
long millis = end - start;
http://java.sun.com/j2se/1.5.0/docs/api
For java.lang.String:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
Return