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: \\\\172.16.1.74\\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
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");
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…
So, I just finished my first actual Adobe Air application.
Version 1.0 is a basic QR code generator. This version just takes a string and embeds it into the QR Code; created for use with URLs, but it will take any string. The next version will have fields for creating contact information QR Codes.
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.
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.