Move a file to a shared drive in Java

Categories Information Technology, Programming

I had a bit of trouble with this, in a program I’m writing at the moment. Every time I tried to move a file to a shared folder, on my computer, it would fail. Turns out, it (apparently) because Java doesn’t necessarily share my mapped drives. Here’s the code that I used to overcome this:

System.out.println("Try to move file");

// create a net use command to map the drive...
String command = "c:\\windows\\system32\\net.exe use Z: \\\\\\f$";
Process p = Runtime.getRuntime().exec(command);

// create an instance of the file to move
File f=new File(".\\myImage.jpg");

// make sure that the file actually exists
boolean fileExists=f.exists();
System.out.println("File Found");
System.out.println("File Not Found");

//create a random number and timestamp, for a unique file name
Random rand = new Random();
int randNum = rand.nextInt();
Date date=new Date();

// Create the new filename
String newFileName=new String("myImage_"+date.getTime()+"_"+randNum+".jpg");

//try to move the file
boolean moved=f.renameTo(new File("Z:\\Home\\ITS\\sigImages\\"+newFileName));
System.out.println("File moved -> "+newFileName);
System.out.println("File Not moved");
}catch(Exception ex){

I’m sure there is a more elegant way of doing this, that more experienced Java programmers will know. But, I could not find too much out there on the web… Hope this helps someone…


Search for non-duplicates bettween two tables.

Categories Information Technology, MySQL, PHP, Programming, Web Development

I recently had some issues trying to make sure that two columns from two different tables were the same.  After some random code writing, I came up with the following MySQL code…  Hope it helps others…

/* return from first table */
$checkTable1=@mysql_query("SELECT table1.column1 FROM table1 LEFT JOIN table2 ON table2.column2 = table1.coumn1 WHERE table2.column2 IS NULL");

/* return from second table */
$checkTable1=@mysql_query("SELECT table2.column2FROM table2 LEFT JOIN table1 ON table1.column1 = table2.column2 WHERE table1.column1 IS NULL");

I’m sure there is a better way to accomplish it, but this worked for my needs…  Just a quick search, and then I added some extra code to update the tables if there are any discrepancies.


13 Super Useful jQuery Content Slider Scripts and Tutorials

Categories Information Technology, JavaScript, jQuery, Programming

via WDL

You’ve probably noticed that a lot of websites lately have a featured area with content that slides or changes in some way. This is a great technique to show several pieces of content in a limited amount of space and a good way to engage the user. If you’ve been wondering how this is accomplished, here are 13 very useful tutorials and scripts that will help you create these types of effects using jQuery.