Canvas to BufferedImage





ranking Sort Sort   |   date Sort Sort   |   member Sort Sort
Syndication

7
Date Submitted Thu. Mar. 16th, 2006 11:17 PM
Revision 1
Coder mattrmiller
Tags File | Java | Move
Comments 1 comments
Move a file quickly in java.
13
Date Submitted Mon. Mar. 20th, 2006 4:52 PM
Revision 1
Coder mattrmiller
Tags Delete | Extension | File | Folder | Java
Comments 0 comments
Deletes all files of a certain extention from a folder.
11
Date Submitted Wed. Mar. 29th, 2006 12:04 PM
Revision 1
Coder mattrmiller
Tags Delete | Directory | Java | Recursive | REMOVE
Comments 1 comments
Recursively delete a directory, emptying all contents.
9
Date Submitted Tue. Apr. 11th, 2006 9:53 AM
Revision 2
Coder mattrmiller
Tags Java | Read | Stream | URLConnection | Write
Comments 0 comments
Reading and writing to a URL connection, thanks to Java.
6
Date Submitted Tue. Apr. 25th, 2006 1:03 PM
Revision 1
Coder mattrmiller
Tags Generate | Java | UID
Comments 3 comments
Another way to generate a unique ID.
-3
Date Submitted Thu. Feb. 23rd, 2006 9:57 AM
Revision 3
Helper jpinkham
Tags Java | JDBC | lightweight | orm | SQL
Comments 1 comments
I actually like SQL. So, things like Hibernate with it's own query language don't quite fit my style. But, I don't want to code the same catch SQLException conn.close over and over either. So, I came up with this.

The idea is you extend SQLCommand (usually anonymously) override getSql(), and call execute() to get a list of whatever objects you are selecting - all the cleanup stuff is taken care of. It also handles nullable attributes more intuitively using ResultSetWrapper and PreparedStatementWrapper so that in your overridden getRow(ResultSetWrapper rs) method, you can call getInt on a nullable column and have it return null - what a concept! Also I like java.util.Date for my dates, so the wrappers convert to/from java.sql.Timestamp.

Right now I've only bothered with some basic types - it should be pretty clear how to add more if you need em.

See what ya'll think.

Oh, it uses JDK 1.5 Generics, but stripping that away would be pretty easy if you wanted 1.2 compliance.
7
Date Submitted Mon. Apr. 3rd, 2006 10:33 AM
Revision 1
Helper jpinkham
Tags Date | intersect | Interval | Java
Comments 1 comments
A handy class I use all the time to encapsulate the idea of whether two events coincide. For example, given a time period representing a shift, and a list of time periods representing transactions or sessions or whatever, find which ones are either totally or partially within the time period. This class make it a bit easier.
9
Date Submitted Mon. Apr. 3rd, 2006 10:41 AM
Revision 1
Helper jpinkham
Tags debug | Java | toString
Comments 1 comments
Do you find yourself implementing toString on your objects all the time, and wondering why (the debugger seems to do a pretty good job of it all by itself)...well, here's a bit of introspection applied to the problem. This is for all those quick debug sessions where you just want to do System.out.println(myComplexObject).

Instead, just do System.out.println(DebugPrint.toString(myComplexObject));
6
Date Submitted Fri. Apr. 7th, 2006 9:50 AM
Revision 1
Helper jpinkham
Tags CLASSPATH | DOS | Java
Comments 2 comments
Here's a nifty trick I often use for testing.

Lets say you have a c:\foo\lib directory full of jarfiles for log4j, javamail...whatever.

Modern J2EE containers do a nice job of letting you deploy a jarfile with your code and have a lib directory full of jarfiles like this, but what if you just want to run a quick client from the command line?

Here's what you do:
12
Date Submitted Tue. May. 9th, 2006 9:36 AM
Revision 1
Helper jpinkham
Tags Email | Java | Validate
Comments 1 comments
Another solution recommends using a text match pattern.
This works, but as long as you've got mail.jar in your classpath anyway, you might as well use this technique instead. (Plus, I think it works with older JDK 1.2+, whereas pattern.compile is 1.4+)

Note that it also accepts a comma-separated list of emails, just like a To: or CC: address line would.