引入jar

<!-- 文件传输 -->
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
            <version>1.19.4</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
        </dependency>

工具类

// filePath: http://192.168.1.99:8068/upload/images/
// fileName: 文件名
public static String uploadFile(byte[] file, String filePath, String fileName) throws Exception {
		File targetFile = new File(filePath);
		if (!targetFile.exists()) {
			targetFile.mkdirs();
		}
		Client client = new Client();
		WebResource resource = client.resource(filePath + fileName);
		resource.put(String.class, file);
		return filePath + fileName;
	}