http conentType file separator

来源:互联网 发布:数控编程的方法有哪些 编辑:程序博客网 时间:2024/06/05 14:25
       when we set contentType to httpResponse, if the file is not sure or if it is a variable, we can use this

       

       private static void setContentTypeHeader(HttpResponse response, File file) {
             MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
             response.headers().set(CONTENT_TYPE,
            mimeTypesMap.getContentType(file.getPath()));
      }

    

         and we can use this to set the file separator

       uri = uri.replace('/', File.separatorChar);


0 0
原创粉丝点击