Here you can find the source of uploadFileToServer(InputStream input, String filename, String usercode, String basePath)
public static String uploadFileToServer(InputStream input, String filename, String usercode, String basePath) throws IOException, FileNotFoundException
//package com.java2s; //License from project: Apache License import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; public class Main { private static String ALIYUN_BASE_PATH = "cloud:/ehome/dev/"; private static String ALIYUN_URL = "https://img.1000.com"; public static String uploadFileToServer(InputStream input, String filename, String usercode) throws IOException, FileNotFoundException { return uploadFileToServer(input, filename, usercode, ALIYUN_BASE_PATH); }//from w w w . j a v a 2s .c o m public static String uploadFileToServer(InputStream input, String filename, String usercode, String basePath) throws IOException, FileNotFoundException { Path cloudPath = Paths.get(URI.create(basePath + usercode + "/" + filename)); Files.copy(input, cloudPath, StandardCopyOption.REPLACE_EXISTING); return ALIYUN_URL + cloudPath.toUri().toString(); } }