May 2005

Prolific PL-3507 Hi-Speed USB & IEEE 1394 Combo to IDE Bridge Controller

I have a generic USB2/IEEE1394 (Firewire) external hard drive enclosure. It is built on the Prolific PL-3507 Hi-Speed USB & IEEE 1394 Combo to IDE Bridge Controller; this is a record of my recent troubles with it. Currently it house’s a Maxtor 6 Y130M0 (120Gb) Hard Drive. I’ve found it to be totally unreliable over …

Prolific PL-3507 Hi-Speed USB & IEEE 1394 Combo to IDE Bridge Controller Read More »

Java Snippet – Using SecureRandom

A better random number generator [java] import java.security.SecureRandom; … public static SecureRandom random = null; static { try { random = SecureRandom.getInstance(“SHA1PRNG”); random.setSeed( random.generateSeed(256) ); } catch( Exception e ) { e.printStackTrace(); } } [/java]

Java Snippet – Fast File Copy

When using JDK 1.4 and above… [java] public static void copyFile(File in, File out) { try { FileChannel sourceChannel = new FileInputStream(in).getChannel(); FileChannel destinationChannel = new FileOutputStream(out).getChannel(); sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel); // or, you can also copy it this way // destinationChannel.transferFrom(sourceChannel, 0, sourceChannel.size()); sourceChannel.close(); destinationChannel.close(); } catch ( Exception e ) { e.printStackTrace(); } } …

Java Snippet – Fast File Copy Read More »

Java Snippet – Recursive Directory Deletion

Returns true on success, false on failure: [java] public static boolean deleteDir(File dir) { if (dir.isDirectory()) { String[] children = dir.list(); for (int i=0; i<children.length; i++) { boolean success = deleteDir(new File(dir, children[i])); if (!success) { return false; } } } return dir.delete(); } [/java]

Scroll to Top