Practical application of File Transfer

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.