`
yshlin
  • 浏览: 61644 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

process

    博客分类:
  • java
阅读更多
//取得所有参数及值;

String url = request.getServletPath() + "?" + request.getQueryString();
     String QueryPath = request.getServletPath() + "?" + request.getQueryString();
     Enumeration enumOne=request.getParameterNames();
     while(enumOne.hasMoreElements()){ 
      String s = (String)enumOne.nextElement(); 
      if(s.equals("method"))
      String queryStr += request.getParameter(s);
      System.out.println("Parameter\t" + s + "\t=\t" +queryStr);
     }

/**
     * 将接收的参数转换编码
     * @param parm
     * @return
     */
    public String enCoderRequestParm(String parm){
  String temp ="";
  try {
   temp= new String(parm.getBytes("ISO-8859-1"), "UTF-8");
  } catch (UnsupportedEncodingException e) {
   e.printStackTrace();
  }
  return temp;
 }

/**
     * 下载模板文件,
     * @param filePath
     * @param response
     */
 @SuppressWarnings("unused")
 protected void downTemplateFileTo(String filePath, HttpServletResponse response) {
  File file = new java.io.File(filePath);
  long long_len = file.length();
  FileInputStream inputStream = null;
  try {
   inputStream = new FileInputStream(file);
   if (inputStream != null) {
    String fname = file.getName();
    response.setContentType("application/x-msdownload");
    String header = "attachment; filename=" + fname;
    response.setHeader("Content-Disposition", header);
    response.setContentLength((int) long_len);
    byte[] b = new byte[2048];
    int len = 0;
    while ((len = inputStream.read(b)) != -1) {
     try {
     response.getOutputStream().write(b, 0, len);
     }catch(Exception ex){
      
     }
    }
   }
   inputStream.close();
  } catch (Exception ex) {
   System.out.println("Download error: ");
   ex.printStackTrace();
  }
 }
 
 
  /**
     * 下载模板文件,
     * @param filePath
     * @param response
     */
 @SuppressWarnings("unused")
 protected void downTemplateFileTo(String filePath, HttpServletResponse response,String fname) {
  
  try {
   fname = new String(fname.getBytes(), "iso8859-1");
  } catch (UnsupportedEncodingException e) {
   e.printStackTrace();
  }
  File file = new java.io.File(filePath);
  long long_len = file.length();
  FileInputStream inputStream = null;
  try {
   inputStream = new FileInputStream(file);
   if (inputStream != null) {
   
    response.setContentType("application/x-msdownload");
    String header = "attachment; filename=" + fname;
    response.setHeader("Content-Disposition", header);
    response.setContentLength((int) long_len);
    byte[] b = new byte[2048];
    int len = 0;
    while ((len = inputStream.read(b)) != -1) {
     try {
     response.getOutputStream().write(b, 0, len);
     }catch(Exception ex){
     }
    }
   }
   inputStream.close();
  } catch (Exception ex) {
   System.out.println("Download error: ");
   ex.printStackTrace();
  } finally{
   File f = new java.io.File(filePath);
   if(f.exists()){
    f.delete();
   }
  }
 }
 
 
 
 
  /**
     * 下载模板文件,
     * @param filePath
     * @param response
     */
 @SuppressWarnings("unused")
 protected void downTemplateFileTo(String filePath, HttpServletResponse response,String fname,String nouser) {
  
  try {
   fname = new String(fname.getBytes(), "iso8859-1");
  } catch (UnsupportedEncodingException e) {
   e.printStackTrace();
  }
  File file = new java.io.File(filePath);
  long long_len = file.length();
  FileInputStream inputStream = null;
  try {
   inputStream = new FileInputStream(file);
   if (inputStream != null) {
   
    response.setContentType("application/x-msdownload");
    String header = "attachment; filename=" + fname;
    response.setHeader("Content-Disposition", header);
    response.setContentLength((int) long_len);
    byte[] b = new byte[2048];
    int len = 0;
    while ((len = inputStream.read(b)) != -1) {
     try {
     response.getOutputStream().write(b, 0, len);
     }catch(Exception ex){
     }
    }
   }
   inputStream.close();
  } catch (Exception ex) {
   System.out.println("Download error: ");
   ex.printStackTrace();
  } finally{
   
  }
 }
 
 /**
  * 创建文件
  * @param filePath 文件的全路径
  * @return
  */
 public File createUploadLogWriter(String filePath) {
  File file = null;
  try {
   file = new File(filePath);
   if (file.exists()) {
    log.info("文件存在");
   } else {
    log.info("文件不存在,正在创建...");
    if (file.createNewFile()) {
     log.info("文件创建成功!");
    } else {
     log.info("文件创建失败!");
    }
   }
  } catch (Exception e) {
   e.printStackTrace();
  }
  return file;
 }
 /**
  * 验证文件的类型是否为传入的类型
  * @param fileName
  * @param type
  * @return
  */
 public boolean checkThisFileType(String fileName, String type) {
  String types[] = fileName.split("\\.");
  String ttype = types[types.length - 1];
  if (ttype.equalsIgnoreCase(type) || ttype.equalsIgnoreCase(type)) {
   return true;
  } else {
   return false;
  }
 }
 /**
  * 创建日志文件
  * fpath = "\\模块目录\\log\\类型Log.txt";
  * @param request
  * @param fpath
  * @return
  */
 public BufferedWriter createLogWriter(HttpServletRequest request, String fpath) {
  String basePath = request.getSession().getServletContext().getRealPath("");
  String fullPath = basePath + fpath;
  BufferedWriter output = null;
  try {
   File f = this.createUploadLogWriter(fullPath);
   output = new BufferedWriter(new FileWriter(f));
  } catch (Exception e) {
   e.printStackTrace();
  }
  return output;
 }

 

分享到:
评论

相关推荐

    Process Monitor中文手册.CHM

    Process Monitor 是windows下高级实时监听工具,用于监视文件系统、注册表、进程和线程的活动。它兼并了两个Sysinternals实用工具Filemon和Regmon的特点,并且增加了一系列的扩展包括丰富而无干扰的过滤全面的事件...

    Aspen Process Explorer 简介

    Aspen Process Explorer 简介 Aspen Process Explorer 是一个功能强大且灵活的过程信息管理系统,旨在帮助管理人员、工程师和操作人员快速而准确地做出决策。它通过组织和显示过程信息来改善操作性能,集成了多种...

    Process v3.4 for SPSS 中介调节效应分析插件

    Process是一款用于spss软件中的调节效应插件,专门进行分析中介效应和调节效应,Process主要应用于SPSS、SAS等传统数据统计分析软件,在SPSS中除了可以可视化操作外,还可以通过Syntax语法等方式操作,扩展功能更为...

    processv34.zip

    spss、sas process包,PROCESS的第3版在中介,调节和条件过程分析简介第二版中进行了描述和记录。单击下面的按钮下载版本3.4(2019年8月12日发行)。这样做时,将根据您的浏览器设置下载.zip存档。PROCESS的安装和...

    Process Monitor v3.53.zip

    Process Monitor是Windows的高级监视工具,可显示实时文件系统,注册表和进程/线程活动。它结合了两个旧的Sysinternals实用程序Filemon和 Regmon的功能,并添加了广泛的增强功能列表,包括丰富的和非破坏性的过滤,...

    c# 调用外部程序,Process初体验

    // Process p = new Process(); // p.StartInfo.FileName = "cmd.exe"; // p.StartInfo.UseShellExecute = false; // p.StartInfo.RedirectStandardInput = true; // p.StartInfo.RedirectStandardOutput = ...

    进程黑客(Process Hacker)Processhacker-3.0.4132

    Process Hacker是一款针对高级用户的安全分析工具,它可以帮助研究人员检测和解决软件或进程在特定操作系统环境下遇到的问题。除此之外,它还可以检测恶意进程,并告知我们这些恶意进程想要实现的功能。 Process ...

    ProcessExcel ProcessExcel

    ProcessExcel ProcessExcel ProcessExcel ProcessExcel ProcessExcel

    英文原版-The Basics of Process Improvement 1st Edition

    Unlikeother books that promote a specific process and performance improvement discipline, this book shows organizations how to achieve success by fixing basic operational issues and problems using a ...

    【048期】SPSS 如何使用PROCESS插件检验调节效应及简单斜率分析.docx

    SPSS使用PROCESS插件检验调节效应及简单斜率分析 SPSS是一种广泛应用于社会科学研究的统计分析软件,PROCESS插件是SPSS的一个插件,主要用于检验调节效应和简单斜率分析。在本文中,我们将详细介绍如何使用PROCESS...

    SAP PO/PI教程 Process Orchestration The Comprehensive Guide

    SAP Process Orchestration The Comprehensive Guide, 2nd Edition SAP流程编制综合指南 1 Introduction to SAP Process Orchestration 1.1 Historical Overview and Evolution 1.1.1 SAP Process Integration ...

    Process Monitor v3.50

    Process Monitor is an advanced monitoring tool for Windows that shows real-time file system, Registry and process/thread activity. It combines the features of two legacy Sysinternals utilities, ...

    Process Monitor v3.2 windows 注册表监控, 文件读写监控

    Process Monitor is an advanced monitoring tool for Windows that shows real-time file system, Registry and process/thread activity. It combines the features of two legacy Sysinternals utilities, ...

    超强任务管理器 Process Explorer (xp,win7/32/64)汉化版

     Process Explorer让使用者能了解看不到的在后台执行的处理程序,能显示目前已经载入哪些模块,分别是正在被哪些程序使用着,还可显示这些程序所调用的 DLL进程,以及他们所打开的句柄。Process Explorer最大的特色...

    ProcessMonitor.zip

    C:\Downloads\ProcessMonitor.C:\Downloads\ProcessMonitor.zipzip

    process.StandardOutput.ReadToEnd 卡死解決方法! 新方法!

    最近做一个编程,用C#调用类似ssh,...网上说使用Process.StartInfo,Process.StandardInput,Process.StandOutput之类的,但是每次都在StandardOutput.Read/ReadToEnd卡死,原因复杂,最主要原因是微乳没有做好.下面是个分析 ...

    Process Monitor 1.35 汉化版

    Process Monitor 1.35 汉化版 这是一个高级的 Windows 系统和应用程序监视工具,由优秀的 Sysinternals 开发,并且目前已并入微软旗下,可靠性自不用说。 此版本的 Process Monitor 增加了多项重要增强功能,包括...

    Process 启动进程Process 启动进程Process 启动进程

    Process 启动进程Process 启动进程Process 启动进程

    spss_process最新版v4.1.rar

    spss_process最新版v4.1

    C语言头文件 PROCESS

    C语言头文件 PROCESSC语言头文件 PROCESSC语言头文件 PROCESSC语言头文件 PROCESSC语言头文件 PROCESSC语言头文件 PROCESSC语言头文件 PROCESSC语言头文件 PROCESSC语言头文件 PROCESSC语言头文件 PROCESSC语言...

Global site tag (gtag.js) - Google Analytics