buildhigh.com

The basics...
About buildhigh.com
Archives
About me
Crap I like
Java Tips
Projects...
JonnyChat
Of me...
Name : Jon
Email : click here
Profession : Programmer

Java Tips

Some useful Java code examples I've run across. I'm starting this from scratch since I lost access to my stuff at work. These are in no particular order, and more examples will appear over time.

FYI, I won't put things here like "You should always use prepared statments when creating queries". You should know this. But you'd be suprised how many "expert" java programmers I've seen who don't use them. There are very few reasons to *NOT* use them folks. Deal with it.

  • Copy an InputStream to an OutputStream.

    This little snippet of code will copy a blob from a resultset (called "part") to an output filestream (filename).

    InputStream is = new BufferedInputStream(rs.getBinaryStream("part")); OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filename)); int b = -1; while ((b = is.read()) != -1) outputStream.write(b); is.close(); outputStream.close();