java - Do not read the file in the package .jar -


this code reads firmware upgrade file jar package , send post request device:

closeablehttpclient client2 = httpclients.createdefault();  httppost post = new httppost("http://" + ip + "/moxa-cgi/uploadfirmwarefile.cgi");  inputstream stream = main.class.getresourceasstream("vport364a_v1_5.rom");  byte b[] = new byte[stream.available()];  stream.read(b);  multipartentitybuilder builder = multipartentitybuilder.create();  builder.addbinarybody("uploadfile", b, contenttype.application_octet_stream, "vport364a_v1_5.rom");  post.setentity(builder.build());  httpresponse response2 = client2.execute(post); 

for unknown reasons, code stopped working execute jar package: firmware upgrade file send nulls. on line:

stream.read(b); 

only nulls already. if run code in ide netbeans, works.why?


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -