ascendingphoto.java

来自「一个仿造淘宝的jsp网站。功能比较完善」· Java 代码 · 共 57 行

JAVA
57
字号
package com.jc.taobao.gjj.logic;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class AscendingPhoto {
    public void IOImage(String clientpath,String servicepath)
    {
        File old = new File(clientpath);
        File newImage = new File(servicepath);
        FileInputStream fis = null;
        FileOutputStream fos = null;

        try {
            if (!old.exists()) {

                return;
            } else {
                fis = new FileInputStream(old);
                
                if(!newImage.exists() ){
                    newImage.createNewFile();
                    
                }
                fos = new FileOutputStream(newImage+"/"+ old.getName());
                
                byte[] temp = new byte[1000];
                int size = fis.read(temp);
                while (size != -1) {
                    fos.write(temp);
                    size = fis.read(temp);
                }
               return ;
            }
        } catch (FileNotFoundException fileNot) {
            fileNot.printStackTrace();
            return;
        } 
        catch(IOException e){
            e.printStackTrace();
            return;
        }
        finally{
            try{
                fis.close();
                fos.close();
                
            }catch(Exception ex){}
            
        }

    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?