你没有给出相应的环境,我也没有办法适合你的程序是在客户端实现这个方法还是在服务端实现这个方法
客户端:你可以提交一点信息以完成服务端执行某个方法
服务端:在IMAGE提交后,或是某个事件后做一个方法

解决方案 »

  1.   

    这是一个web程序,在浏览器端点击某个按钮后,执行一个方法,这个方法实现文件的复制。(这个文件的复制是在服务器端将一个文件复制到另一个文件夹里)
    我想知道的是如何复制文件。不知道我有没有表达明白
      

  2.   

    凄凉,Up一下我解决了,代码如下:
    package cscec.news;
    import java.io.*;
    public class copyFile{
    public void copyFile(){}
    public void copyFiles(String fileSource,String fileAim){
    File myFile1,myFile2;
    //FileWriter out;
    FileInputStream myfileStream;
    FileOutputStream myfileOutStream; 
    DataInputStream dataInStream;
    DataOutputStream dataOutStream;
    String filePath1=fileSource;
    String filePath2=fileAim;
    int iLength;
    myFile1 = new File(filePath1);
    myFile2 = new File(filePath2);
    try{
    if(!myFile1.exists()){
    myFile1.createNewFile();
    }
    if(!myFile2.exists()){
    myFile2.createNewFile();
    }
    }catch (IOException e)
    {
    System.out.println(e.getMessage());
    System.out.print("it does not exist----------");
    }
    //打开输入流并读信息
    try{
    myfileStream = new FileInputStream(myFile1);
    dataInStream = new DataInputStream(myfileStream);
    myfileOutStream = new FileOutputStream(myFile2);
    dataOutStream = new DataOutputStream(myfileOutStream);
       while((iLength=dataInStream.read())!=-1){
         //输出\r
         dataOutStream.write(iLength);
         System.out.print(iLength);
       }
       dataInStream.close();
       myfileStream.close();
       myfileOutStream.close();
       dataOutStream.close();
       }catch(IOException e)
       {
    System.out.println(e.getMessage());
    }
      
    }


    }