String date = new java.text.SimpleDateFormat("MM-dd-yyyy").format(new java.util.date());
upload.uploadfile("192.168.0.210", "muruganp", "vm4snk", "/home/media/Desktop/FTP Upload/+date+"_RB.zip"", "/fileserver/f开发者_如何学Goilesbackup/Emac/+date+"_RB.zip"");
uploadfile is a function which uploads the file 10-20-2010_RB.zip to the server location.
But since I do have the string "date" in my path, few errors like illegal start of expression occurs.
If I try the same as below, the program works fine.
upload.uploadfile("192.168.0.210", "muruganp", "vm4snk", "/home/media/Desktop/FTP Upload/20-10-2010_RB.zip", "/fileserver/filesbackup/Emac/20-10-2010_RB.zip");
For some reasons, I am in a compulsion to insert the string in the file path. How can I attain the end result ? Kindly advise.
You're getting syntax errors because you don't have quote marks correct in the string concatenation. You need to change
upload.uploadfile("192.168.0.210", "muruganp", "vm4snk",
"/home/media/Desktop/FTP Upload/+date+"_RB.zip"",
"/fileserver/filesbackup/Emac/+date+"_RB.zip"");
to
upload.uploadfile("192.168.0.210", "muruganp", "vm4snk",
"/home/media/Desktop/FTP Upload/"+date+"_RB.zip",
"/fileserver/filesbackup/Emac/"+date+"_RB.zip");
Maybe, you want "/home/media/Desktop/FTP Upload/" + date + "_RB.zip"
instead of "/home/media/Desktop/FTP Upload/+date+"_RB.zip""
? I'm not exactly sure how this even compiles.
Also, you have month and day switched around in your SDF pattern. (So, date would be converted to 10-20-2010
string and not 20-10-2010
.)
I see
"/home/media/Desktop/FTP Upload/+date+"_RB.zip""
It should be
"/home/media/Desktop/FTP Upload/"+date+"_RB.zip"
(I think it's a copy/paste typo since it won't work)
精彩评论