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

c# SetCompatibleTextRenderingDefault must be called before the first -

C#.NET Oracle.ManagedDataAccess ConfigSchema.xsd -

c++ - Fill runtime data at compile time with templates -