blob: 8f0b5ea7e753b64494a5fd95078f4704adf9acf8 [file] [log] [blame]
package org.eclipse.wst.validation.tests;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Some miscellaneous helper methods.
* @author karasiuk
*
*/
public class Misc {
private static DateFormat _df = new SimpleDateFormat("HH:mm:ss.SSSS"); //$NON-NLS-1$
public static void close(InputStream in){
if (in == null)return;
try {
in.close();
}
catch (IOException e){
// eat it
}
}
public static void close(OutputStream out) {
if (out == null)return;
try {
out.close();
}
catch (IOException e){
// eat it
}
}
/**
* Write a line to the console for debugging.
* @param line
*/
public static void log(String line){
System.err.println(timestampIt(line));
}
public static String timestampIt(String line){
Date date = new Date();
long thread = Thread.currentThread().getId();
return _df.format(date) + " " + thread + " " + line;//$NON-NLS-1$//$NON-NLS-2$
}
public static void log(StringBuffer b){
log(b.toString());
b.setLength(0);
}
public static void niy(String msg){
if (msg == null)msg = "Sorry, this function is not implemented yet"; //$NON-NLS-1$
throw new RuntimeException(msg);
}
}