commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Agnes Laffitte" <agneslaffi...@gmail.com>
Subject Displaying the output file using apache fileupload
Date Fri, 29 Aug 2008 17:21:32 GMT
Hello,
by using java i have read an input file and written the output file. Now I
want the server to display the content of the output file.
I have the output file name, and the method I used to write the output file
was by using the following fragment of code:
  PrintWriter out = new PrintWriter(System.currentTimeMillis() + outFile);

out.println("***************************************************");
            out.println("*
*");
            out.println("*              RESULTS FROM SIMUROUTE PROJECT
*");
            out.println("*
*");

out.println("***************************************************");

        out.println("\r\n");

out.println("***************************************************");
            out.println("*                 COSTS MATRIX
*");

out.println("***************************************************");
            out.println("\r\nCOSTS MATRIX:\n");
            for (int i = 0; i < nodesList.size(); i++)
                for (int j = 0; j <= i; j++)
                    out.println(i + " " + j + " " + Distance1[i][j]);

            out.close();
        }
        catch (IOException exception)
        {
            System.out.println("Error processing output file: " +
exception);
        }

    }
Let me know how to display this content to the client. I have code that
receive the file from the client using the file upload widget and
this fragment of code:
private FileItem getFileItem(HttpServletRequest request) {
        FileItemFactory factory = new DiskFileItemFactory();
        ServletFileUpload upload = new ServletFileUpload(factory);

        try {
            List<FileItem> items = upload.parseRequest(request);

            for (FileItem item: items) {
                if (!item.isFormField()
                        && "uploadFormElement".equals(item.getFieldName()))
{
                    return item;
                }
            }
        } catch (FileUploadException e) {
            return null;
        }

        return null;
    }

Your attention to this matter is highly appreciated.
Sincerely,
Agnes Laffitte

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message