Copy a file (optionally marking as temporary)
12
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.
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.
6
Another way to generate a unique ID.
9
Reading and writing to a URL connection, thanks to Java.
6
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:
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:
9
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));
Instead, just do System.out.println(DebugPrint.toString(myComplexObject));
7
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.
11
mattrmiller
Recursively delete a directory, emptying all contents.
7
Need to GZip a file using Perl?
Use Compress::Zlib.
This is a simple perl script which creates a GZip file.
Use Compress::Zlib.
This is a simple perl script which creates a GZip file.
8
Is this file the same as that file? The files may or may not be binary. We could compare the modify dates, or the sizes. But, those are not very accurate to know if a file has really changed.
Introducing MD5 Checksum. We can feed the files into Digest::MD5 in binary mode.
This is a great way to do Incremental Backups.
This is also an easy way to verify checksums when downloading files from the internet which list their MD5 Checksums.
You'll need the Digest::MD5 Perl Module.
Introducing MD5 Checksum. We can feed the files into Digest::MD5 in binary mode.
This is a great way to do Incremental Backups.
This is also an easy way to verify checksums when downloading files from the internet which list their MD5 Checksums.
You'll need the Digest::MD5 Perl Module.
8
Copies files from nested folders into one source, flat directory.









