public marks

PUBLIC MARKS from sylvainulg with tags programming & java

2011

ServerSocket (Java Platform SE 6)

SO_REUSEADDR for Java -- how to avoid java.net.BindException (at the risk of odd TCP state) [code] ServerSocket x = new ServerSocket(); x.setReuseAddress(true); x.bind(new InetSocketAddress(port)); [/code]

2010

Remonter silencieusement une checked-exception - adiGuba:Blog - Club des décideurs et professionnels en Informatique

(via)
petit discours sur les exceptions en Java. j'aime bien le } catch (IOException e) { throw new RuntimeException(e); } et public class UncheckedException extends RuntimeException { public UncheckedException(Throwable source) { super(source); } @Override public Throwable fillInStackTrace() { // On empêche la génération du stacktrace. return this; } }

File.deleteOnExit is evil

(via)
better tell the students not to use it.

Bug ID: 4199068 Please return the functionality of getenv()

(via)
Due to overwhelming demand we are going to reconsider this position for the 1.5 release. -- xxxxx@xxxxx 2002/4/30 ... so is it available or not, after all ?

2009

DataInput (Java 2 Platform SE 5.0)

Silverbullet when doing networking IO. Features readLine, readInt, readFully(byte[])

The For-Each Loop

(via)
void cancelAll(Collection<TimerTask> c) { for (TimerTask t : c) t.cancel(); }

Java 2 Platform SE v1.3.1: Class BufferedReader

(via)
you want readline() for implementing HTTP in java ? here it is, not in BufferedInputStream

Java and unsigned int, unsigned short, unsigned byte, unsigned long, etc. (Or rather, the lack thereof)

(via)
"Well, you're probably not going to like this... The answer is, you use the signed types that are larger than the original unsigned type"

socket : Java Glossary

(via)
interesting hints about socket programming in Java, though i don't know how much of that is accurate/up to date (e.g. graceful shutdown looks odd)

MessageDigest (Java Platform SE 6)

MessageDigest md = MessageDigest.getInstance("SHA");

2007

javax.xml.xpath (Java 2 Platform SE 5.0)

(via)
xpath pour accéder aux documents XML en Java (comme si c'était des répertoires)