java - The method write(int) in the type BufferedWriter is not applicable for the arguments (byte[]) -
i beginner spring,
i trying download file net , store in local disk getting compilation error mentioned in tile
i tried make responseentity , json string worked says image damaged or not supported when try open image
my code:
public static void main(string arg[]) throws ioexception { httpheaders requestheaders = new httpheaders(); //requestheaders.setacceptencoding(contentcodingtype.identity); httpentity<?> requestentity = new httpentity<object>(requestheaders); // create new resttemplate instance resttemplate resttemplate = new resttemplate(); // add string message converter resttemplate.getmessageconverters().add(new stringhttpmessageconverter()); // make http request, marshaling response string responseentity<byte[]> response = resttemplate.exchange("http://www.nndb.com/people/954/000354889/duke-kahanamoku-2-sized.jpg", httpmethod.get, requestentity,byte[].class); file file = new file("/users/crohitk/desktop/image.jpg"); // if file doesnt exists, create if (!file.exists()) { file.createnewfile(); } byte[] json =response.getbody(); filewriter fw = new filewriter(file.getabsolutefile()); bufferedwriter bw = new bufferedwriter(fw); bw.write(json); bw.close(); system.out.println("done"); system.out.println(response.getbody()); }
writer used write characters. use outputstream
write bytes file.
Comments
Post a Comment