I have REST Webservice which give me the file from the system:
@Stateless
@Path("/print")
public class PictureWebservice {
@GET
@Path("/startPrint")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response getFile() {
String path = "/mypath.JPG";
File file = new File(path);
return Response.ok(file, MediaType.APPLICATION_OCTET_STREAM)
.header("Content-Disposition", "attachment; filename=\"" + file.getName() + "\"" ) //optional
.build();
}
}
If I open my browser and type in: http://192.168.2.11:8080/rest/print/startPrint
=> Everything works fine and I got the image.
But now I would like to have my file on the other PC: File file = new File("http://192.168.2.11:8080/rest/print/startPrint")
But than I got an error "FileNotFoundException". What is wrong? I guess the path is not valid?