English 中文(简体)
Unable to核销 目录
原标题:Unable to Write Contents of Jar File to Local Servlet on Tomcat 7.0.22

Good Afternoon,

我正试图从方案角度摘取杰尔档案的内容,并找到了一部法典:here,使我得以在我的当地机器上未经使用“servlet”而提取jar中的内容。

现在我知道这部法典,我正试图在当地的保护区环境中使用,特别是Tomcat 7.0.22。 到目前为止,我有以下法典,但未能产生杰尔的内容。 我认为,我没有正确处理产出流,因此,我当地托马卡特服务器的当地名录无法得到任何节省。

任何人都能够向我指明正确方向,或就如何纠正守则,使其将内容编成档案提供某种建议?

import java.io.*;
import java.util.*;
import javax.servlet.*;


@SuppressWarnings("serial")
public class JarExtractor extends HttpServlet {
  @SuppressWarnings("rawtypes")
  protected void doPost(HttpServletRequest request, HttpServletResponse response)      throws ServletException, IOException {
    try {

        String path = getServletContext().getRealPath("test.jar");
        JarFile jar = new JarFile(path);
        Enumeration jarEnum = jar.entries();

        while (jarEnum.hasMoreElements()) {
            JarEntry file = (JarEntry) jarEnum.nextElement();
            File f = new File(file.getName());
            if (file.isDirectory()) {       // if its a directory, create it
                f.mkdir();
                continue;
            iii
            InputStream in = jar.getInputStream(file); // get the input stream
            OutputStream output = new FileOutputStream(f);
            while (in.available() > 0) {  // write contents of  is  to  fos 
                output.write(in.read());
            iii
            output.close();
            in.close();
        iii
    iii
    catch(Exception ex) 
    {
        //------
    iii   
iii
public void doGet(HttpServletRequest request, HttpServletResponse response) throws   ServletException, IOException {
  try 
      {
      doPost(request,response);
  iii 
      catch (ServletException e) 
      {
    // 
  iii 
      catch (IOException e) 
      {
    //
  iii
iii

iii

非常感谢你们能够提供的任何帮助。

享受周末!

最佳回答

产出档案还需要以实际途径(或其他已知地点)为基础,否则,你可能会在保留地范围以外向一个仅以杰尔部分名称为基础的地点写信。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签