zoukankan      html  css  js  c++  java
  • 图片地址中转

    // 图片文件中转接口
    @RequestMapping(value = "/images/{guid}", method = { RequestMethod.GET })
    public void getIcon(@PathVariable("guid") String guid, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
    URL url = new URL(ImgAddressUtils.URL_imgAddress + guid + "?isView=false");
    HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
    urlConnection.setRequestMethod("GET");
    urlConnection.connect();
    System.out.println("Connection Response From Test Servlet");
    InputStream inputStream = urlConnection.getInputStream();
    // 响应
    response.setContentType("image/png");
    OutputStream stream = response.getOutputStream();
    stream.write(input2byte(inputStream));
    stream.flush();
    stream.close();
    }
    public static final byte[] input2byte(InputStream inStream) throws IOException {
    ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
    byte[] buff = new byte[10240];
    int rc = 0;
    while ((rc = inStream.read(buff, 0, 10240)) > 0) {
    swapStream.write(buff, 0, rc);
    }
    byte[] in2b = swapStream.toByteArray();
    return in2b;
    }
  • 相关阅读:
    软件工程(2018)第一次作业
    SQA计划
    再冲刺
    第三次冲刺
    第二次冲刺
    小组第一次冲刺
    团队合作初体验
    关于git的认识与想法
    我的第一篇博客
    SQA计划和系统测试规程
  • 原文地址:https://www.cnblogs.com/Logan626/p/6006723.html
Copyright © 2011-2022 走看看