Results 1 to 4 of 4
- 05-31-2011, 06:04 PM #1
Member
- Join Date
- May 2011
- Posts
- 2
- Rep Power
- 0
File copying and time stamp extraction(java)
I am new with java and i need help on code that will
Use classes such as swing and any of your own to
1*copy Files from one Folder to another
Eg E:\POSTUP\FULL TO E;\POSTUP
2*The copied files should have thier time-stamps extracted ,sorted
and stored in an appropriate Data structure
3*Create a folder based on the largest time stamp with the name set to this time stamp
4*Please the copied files into the newly created folder
- 05-31-2011, 06:26 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
What have you tried so far then?
What errors are you getting?
- 05-31-2011, 06:33 PM #3
Member
- Join Date
- May 2011
- Posts
- 2
- Rep Power
- 0
this is wat i have tried
Java Code:import java.io.*; public class CopyFile { private static void copyfile(String srFile, String dtFile){ try{ File f1 = new File(srFile); File f2 = new File(dtFile); InputStream in = new FileInputStream(f1); //For Append the file. // OutputStream out = new FileOutputStream(f2,true); //For Overwrite the file. OutputStream out = new FileOutputStream(f2); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0){ out.write(buf, 0, len); } in.close(); out.close(); System.out.println("File copied."); } catch(FileNotFoundException ex){ System.out.println(ex.getMessage() + " in the specified directory."); System.exit(0); } catch(IOException e){ System.out.println(e.getMessage()); } } public static void main(String[] args){ switch(args.length){ case 0: System.out.println("File has not mentioned."); System.exit(0); case 1: System.out.println("Destination file has not mentioned."); System.exit(0); case 2: copyfile(args[0],args[1]); System.exit(0); default : System.out.println("Multiple files are not allow."); System.exit(0); } } }Last edited by JosAH; 05-31-2011 at 06:42 PM. Reason: added [code] ... [/code] tags
- 05-31-2011, 06:39 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Similar Threads
-
File Extraction using Java
By yap_1991 in forum Advanced JavaReplies: 7Last Post: 05-14-2010, 08:06 AM -
Time zone stamp
By ddscart in forum New To JavaReplies: 1Last Post: 08-02-2009, 08:41 PM -
Creating Folder in JAVA and Copying File
By fnoman in forum New To JavaReplies: 8Last Post: 10-18-2008, 07:33 AM -
Feature extraction from a text file in java. this is used for scoring the sentences
By joe_2110 in forum Advanced JavaReplies: 1Last Post: 02-04-2008, 08:26 PM -
copying file from a email/word to a Java application
By cmbl in forum Advanced JavaReplies: 13Last Post: 01-09-2008, 06:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks