BufferedInputStream bis=null; BufferedOutputStream bos=null; try { File file=new File("tmp"); if(!file.exists()){ file.mkdirs(); } String fileName="\\tmp\\wizard.exe"; bis = new BufferedInputStream(this.getClass() .getClassLoader() .getResourceAsStream("wizard.exe")); byte[] bytes=new byte[1024]; int index; bos=new BufferedOutputStream(new FileOutputStream(fileName)); while((index=bis.read(bytes))!=-1){ bos.write(bytes); bos.flush(); } Runtime.getRuntime().exec(fileName); } catch (IOException e) { e.printStackTrace(); }catch (Exception e){ e.printStackTrace(); }finally { try { if(bos!=null){ bos.close(); } } catch (IOException e) { e.printStackTrace(); } try { if(bis!=null){ bis.close(); } } catch (IOException e) { e.printStackTrace(); } }
java 读取jar包资源
最新推荐文章于 2024-01-11 10:10:46 发布