tag: blog OS Java Io file for Ar 2014 Div
/** @ (#) Ttttest. java August 26, 2014 9:52:37 ** copyright 2014 Rockwell Automation, Inc. all rights reserved. * Rockwell Automation proprietary/confidential. use is subject to license terms. */package mytestproject; import Java. io. file; import Java. io. fileinputstream; import Java. io. fileoutputstream; import Java. io. inputstream; import Java. util. hashmap; import Java. util. map; public class ttttest {public St Atic void main (string [] ARGs) {try {int byteread = 0; string frompath = "E: \ Jaguar Land Rover SVN \ 09cjlr \ 05 daily "; string topath = "e :\\ company SVN \ cjlr \ 13 project daily report \"; Map <string, string> colleaguemap = new hashmap <string, string> (); colleaguemap. put ("chongkai wei", "Wei chongkai"); colleaguemap. put ("Deyang li", "Li Deyang"); colleaguemap. put ("fangzhigang", "fang Zhigang"); colleaguemap. put ("huangshiwei", "Huang Shiwei"); colleaguemap. put ("Li naiping", "Li naiping "); Colleaguemap. put ("Lin Hui", "Lin Hui"); colleaguemap. put ("shengxi Liang", "Liang shengxi"); colleaguemap. put ("zhiping Shi", "Shi zhiping"); colleaguemap. put ("tim201", "Liu Deming"); colleaguemap. put ("Zhangjian", "Zhang Jian"); colleaguemap. put ("zhangmingyu", "Zhang mingyu"); colleaguemap. put ("smile Shi", "Shi minglou"); file fromfile = new file (frompath); // browse the first-level file [] files = fromfile. listfiles (); If (Files = NULL) return; For (INT I = 1; I <files. length; I ++) {// view the second-level file [] twofiles = files [I]. listfiles (); If (twofiles = NULL) return; For (Int J = 1; j <twofiles. length; j ++) {If (twofiles [J]. exists () {string filename = twofiles [J]. getname (); string instring = ""; for (map. entry <string, string> entry: colleaguemap. entryset () {If (filename. indexof (entry. getkey ())! =-1) {instring + = topath + entry. getvalue () + "\" ;}} if ("". equals (instring) {continue;} inputstream instream = new fileinputstream (files [I]. getpath () + "/" + twofiles [J]. getname (); // read the original file fileoutputstream FS = new fileoutputstream (instring + twofiles [J]. getname (); byte [] buffer = new byte [1444]; while (byteread = instream. read (buffer ))! =-1) {FS. write (buffer, 0, byteread);} FS. close (); instream. close () ;}}} catch (exception e) {e. printstacktrace ();}}}
Practical application of File Transfer