package com.client; import java.io.InputStream; import java.net.URL; import javax.ws.rs.core.MediaType; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; public class ProjectClient { public static void main(String[] args) throws Exception { final String BASE_URI = "http://172.23.204.15:8080/"; Client c = Client.create(); WebResource service = c.resource(BASE_URI); // Collect File from the path specified URL url = new URL("file:///C:\\personal\\scan0002.jpg"); System.out.println("File Size: "+url.getFile().length()); // Covert File into Stream InputStream source = url.openStream(); // POST the request ClientResponse response = service.path("restweb/jersey/project").type( new MediaType("image", "jpg")).post(ClientResponse.class, source); System.out.println("Response Status : " + response.getEntity(String.class)); } }