Re: File Input Streams FileNotFoundException

Hi,
I'm having problems with file input streams.
The program is supposed to read from an external file but when I run it in Sun ONE Studio 4 (update 1), it gives me a FileNotFoundException (The system cannot find the file specified). The file, class.dat, is in the same folder as the .java and .class files.
Anyway, so I run the program through MS-Prompt commands and there is no problem. It executes fine and gives the right output. Go figure.
Can anyone shed some light on what is going on? Anyone else with the same problem? Is there something I need to configure in SunStudio? Please help...
Thanks
The code is taken directly from Sams Java in 21 days.
// code
import java.io.*;
public class ReadBytes {
public static void main(String[] arguments) {
try {
FileInputStream file = new
FileInputStream("class.dat");
boolean eof = false;
int count = 0;
while (!eof) {
int input = file.read();
System.out.print(input + " ");
if (input == -1)
eof = true;
else
count++;
file.close();
System.out.println("\nBytes read: " + count);
} catch (IOException e) {
System.out.println("Error -- " + e.toString());

FileInputStream file = new FileInputStream("class.dat");Is this the line that is giving you the error message? Always, when trying to open a disk file, give the full path. This is because, FileNotFoundException is thrown only in cases when your file cannot be found by your program. But you say that the file exists.
Try giving your full path for the file...like:
FileInputStream file = new FileInputStream("C:/Program Files/class.dat");
//Ofcourse your path will be different. This is just an example!So try giving the full path and let me know.
Vijay :-)

Similar Messages

  • How to get file input stream from the client machine by JSF Fileupload API?

    Dear Friends,
    How to get the file input stream from the client machine by JSF HtmlFileupload or fileupload API. At present, if i execute the file upload code in the client machine, it is able to get the local path of the file and looking for the file in server machine. So i am getting FileNotFoundException.
    E.g., If a file is located at client machine at following location means "C:\Test\Test.txt",
    uploadClass.getFileuploadComponent().getFilename().toString() returns "C:\Test\Test.txt". But it is looking for that file in server and throwing FileNotFoundException.
    Please post your replies soon.
    Thanks,
    JP

    Depends on which version of JSF you're using. If JSF 1.2, I wouldn't even bother trying to hack this into JSF itself unless you can use something like Seam 2 or richfaces.
    http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/rich_fileUpload.html
    http://docs.jboss.org/seam/2.2.1.CR3/reference/en-US/html/controls.html#d0e29259 (look for s:fileUpload)
    But if I were you, a simple non-jsf form with a servlet works best for taking file uploads.
    As for JSF 2.0, there are other ways of getting it done.
    http://balusc.blogspot.com/2009/12/uploading-files-with-jsf-20-and-servlet.html

  • Does File Input stream encode data

    Hi,
    When I retrieve a binary stream of an image from a database and print out all the bytes and then retrieve data with a FileInputStream from the same image stored as a file, and print the results, the 2 printouts are completely different. Can anyone explain why?
    Thanz

    However, the InputStreams do treat bytes as signed entities (-128 to +127 rather then 0 to 255). If you just print these out then you will get odd results which do not match the data you are expecting.
    If you do the following
    int tmp = b & 0xFF;
    where b is a byte from your input then tmp will contain the unsigned value of that byte rather then the signed value.
    matfud

  • File Input Stream problem

    i have a text file that i want to read to be my input into my database in db4o. i was looking through the websites. like http://java.sun.com/javase/6/docs/api/java/io/FileInputStream.html
    and
    http://www.java2s.com/Code/JavaAPI/java.io/FileInputStreamavailable.htm
    there were different types too. like FileReader, FileInputStream. can anyone explain to me the differences between this two?
    below is an example on how inside my text file is going to look like
    Jack | China | 23
    Helen | Holland | 34
    Jenny | US | 34
    Micheal | Brazil | 23
    different attributes is separated by "|". i need to capture all this from a text file and store it in my db4o database. maybe someone could guide me on this? i am very new in java so forgive me if i am wrong. Thanks alot

    ok. thanks alot. i will look into it
    the "|" is because i want to separate different
    attributes by using symbol
    for example:
    Name | Address | Age
    Alex | Australia | 34
    Jack | Malaysia | 32
    Kate | Africa | 11
    Holmes | California | 54
    from there, this will be captured by the
    BufferedReader (because this is use to capture text)
    and read it and then stored inside the db4o. the
    problem now is how can i capture the data and
    automatic separate it as different field with this
    "|" symbol
    Message was edited by:
    erickhHow about using Scanner:
    Scanner inFile = new Scanner(new FileReader("a:\\file.txt"));

  • Using file input stream

    hello,
    i have the following problem.I have a file which consists of characters. I have to consider each character at a time for further manipulation, so in order to that i need to store it in an array..i have read the file using the following ..
    public class fileinput
    public static void main(String args[]) throws IOException
    int size;
    InputStream f = new FileInputStream("laser.txt");
    System.out.println("total available bytes:" +(size=f.available()));
    Now is it possible to store this file into a array ..when i use the following i'm getting an error coz "f.read()" returns an integer so it is incomaptible....
    byte b[]=new byte[size];
    for(int i=1;i<=size;i++)
    b=f.read();
    somebody plz help...

    1. It is really inefficient to read 1 byte at a time. You might do better to read all the bytes you can get and then see what's in the byte[]
    2. When using read(), here's what you want
    int b;
    while ( b = in.read() != -1) {
    byte bb = (byte) b;

  • File Input Stream

    Hello !
    The FileInputStream has a constructor which uses FileDescriptor object as "FileInputStream(FileDescriptor fdobj)"
    The practical use of FileDescriptor object is the FileInputStream and FileOutputStream to contain it.
    Can someone help me how to make an elaborate use of it ? I want to use it in some manner in the following program .
    God bless you.
    NADEEM.
    import java.io.* ;
    public class CopyingText {
    public static void main(String args[])  { 
    Thread t = new Thread();
      try {
       System.out.println("Enter java CopyingText Source.txt Target.txt");
       FileInputStream  a = new FileInputStream(args[0]);
       FileOutputStream b = new FileOutputStream(args[1],true);        
       System.out.println("Source size: " + a.available());
       System.out.println(a.getFD());
        CopyingTxt rw  = new CopyingTxt(a,b);
        rw.fileCopying();
    //    rw.bytesAvailable();             Giving IOException: Bad file descriptor : Reason ?
      } catch(Exception e) {
        System.out.println("Exception : main() :" + e );
        t.dumpStack();
    class CopyingTxt   {
      private int i  , j  ;
      FileInputStream  fa ;
      FileOutputStream fb ;
      CopyingTxt(FileInputStream a, FileOutputStream b) {
       fa = a ;
       fb = b ;
      public int bytesAvailable() throws IOException {
       System.out.println(fa.getFD());
       System.out.println(fa.available());
        return fa.available() ;
      public void fileCopying() throws IOException {
       do {
        i = fa.read();
        j++ ;                                  
        if(i != -1) fb.write(i) ;
       } while(i != -1);                       //EOF condition  -1 .
       System.out.println("Bytes read : " + (j-1) + " / " + fa.available());
       bytesAvailable();
       fa.close();
    //    fa.finalize();
       fb.close();
    //    fb.finalize();
    }

    Please don't crosspost. It cuts down on the effectiveness of responses, leads to people wasting their time answering what others have already answered, makes for difficult discussion, and is generally just annoying and bad form.

  • What's the fastest input stream reader?

    Here's my candidate for the fastest stream reader. My interest and testing is with file input streams, but it's nice to support any stream.
         public static String readStream(InputStream is) throws IOException{
              int i, length = 0;
              StringBuffer s = null;
              char[] c = null;
              InputStreamReader isr = new InputStreamReader(is);
              while(length != -1){
                   length = is.available();
                   if(c == null) c = new char[length];
                   isr.read(c, 0 , length);
                   i = isr.read();
                   if(i == -1){
                        if(s == null) return String.copyValueOf(c);
                        else break;
                   }else{
                        if(s == null) s = new StringBuffer();
                        s.append(c, 0, length);
                        s.append((char)i);
              return s.toString();
         }

    I do have a separate function that's optimized for file reading. I have tried the simpler implementation, and it is slower.
    The reason I'm reading into a StringBuffer is that I have a DOM framework that allows you to load an xhtml document, do stuff, and then print out the result. I have Styles which allow you to merging a document with a style document and then in your project specific code, modify the resulting document. In one case, my style document is located on a remote machine and has the following:
    <link rel="stylesheet" href="<!--SOURCEURL-->style.css" type="text/css" media="all"/>
    I allow the Style class to override a "replaces" function that does string replacements and thus allows the non-xml compliant comment to be replaced by the appropriate URL prefix for the remote machine. I admit this probably isn't the best way to do it, since the comment makes the document invalid. I'd like to change to a better way, but I'd still like to keep the option of doing textual replaces on the input document before loading it into DOM. This may be a requirement since it is the convension that was previously used before we started using DOM.
    As for bounded size, I figure the StringBuffer is going to be a lot smaller than the DOM representation anyway. And, neither should be that significantly large.

  • How do I return an input stream from a text file

    Suppose there's a class with methods..
    one of the methods is something like..
    public int value() and has a return statement at the end obviously for returning an int value..
    Another method reads a text file and creates an input stream..
    Scanner data  = new Scanner(new File(input.next()));
    I want to return the data when I do a call to this method, but I'm not sure what the method heading would look like..

    flounder wrote:
    Are we supposed to magically know what those errors are? Do you think that copying and pasting the exact error messages and indicating the lines they occur on would be useful to us?Sorry about that..
    I've replicated the same code below; and put the number of the line where the error is.
    +cannot find symbol variable read     [line 21]+
    +cannot find symbol variable read     [line 23]+
    +cannot find symbol variable read     [line 29]+
    +cannot find symbol variable read     [line 31]+
    +cannot find symbol variable inputStream     [line 44]+
    +calculate() in textInput cannot be applied to (java.util.Scanner)     [line 57]+
    the reason I have the _______ for the createInputStream() method is because I'm not really sure what the heading type should be to return the input stream.
    import java.io.*;
    import java.util.*;
    public class textInput
              public void requestFileName()
                   Scanner input = new Scanner(System.in);
                   System.out.print("Enter file name: ");
              public _______ createInputStream() throws FileNotFoundException
                   Scanner input = new Scanner(System.in);
                   Scanner read = new Scanner(new File(input.next()));
                   return read;
              public void calculate() throws IOException
    21           double max;
                   double min;
    23            int count = 0;
                   double total = 0;
                   if (read.hasNextDouble())
                        double temp = read.nextDouble();
    29                 max = temp;
                        min = temp;
    31                 count++
                        total += temp;
                        while (read.hasNextDouble())
                             double current = read.nextDouble();
                             count++;
                             min = Math.min(current, min);
                             max = Math.max(current, max);
                             total += current;
                   System.out.println("Max of: " + max);
                   System.out.println("Min of: " + min);
    44            System.out.println("Average of " + total/count);
              public void close() throws IOException
                   inputStream.close();
              public static void main(String[] args)
                   textInput run = new textInput();
                   try
    57                 run.requestFileName();
                        run.createInputStream();
                        run.calculate();
                        run.close();
                   catch(FileNotFoundException e)
                        System.out.println("File not found.");
                        System.exit(0);
                   catch(IOException e)
                        System.out.prinln("File not found.");
                        System.exit(0);
    }

  • Parse XML input stream (no .xml file)?

    i have a java applet calling a web service that returns XML data as an input stream (char by char from SOAP) to this applet. if i append a all the chars to a string, is there some XML tool that will parse the string as if it were an XML document (like a getElement functions)?
    the applet cannot write the data to a .xml file, and i don't want to mess around with .jarsigning. any ideas?
    thanks,
    jonathan

    The XML parsers you are likely to be using support receiving input from a variety of sources besides files. For example you could parse XML from a String variable by passing a StringReader wrapping that String to the parser. Check the documentation for more details.

  • How to read a file as an input stream after it's posted in an HTML form ?

    Hello,
    I want to read client file after it's posted in an HTML form. But, I don't want to upload it to filesystem or database. I want to read posted file as an input stream. How can I do that ?
    thanks in advance...

    A couple of things. If you have a FILE field in your form, the enctype of the form must be multipart/form-data. Check this link
    http://www.htmlhelp.com/reference/html40/forms/form.html
    Also, when a file is uploaded you cannot use the regular methods to get at the name/value pairs or the file itself. You'll have to use a utility like MultiPartRequest or write your own based on the RFC for Multipart requests.
    http://www.servlets.com/cos/javadoc/com/oreilly/servlet/MultipartRequest.html
    You will need some temporary file system to store this and then delete it when you are done with it.
    hth

  • Document file or input stream is not set.

    Error sending mail :Exception Thrown
    oracle.apps.xdo.delivery.DeliveryException: Document file or input stream is not set.
    at oracle.apps.xdo.delivery.AbstractDeliveryRequest.submit(AbstractDeliveryRequest.java:1154)
    Delivery manager:
    Can some one tell me what was wrong with this,
    I check my document path I can describe it
    When i send one attachment it works with the same path
    but when I use multiple attachment it gives then error
    Attachment m = new Attachment();
    m.addAttachment("/fapps/oracle/fintstcomn/java/chami/test.pdf","test.pdf","application/pdf");
    m.addAttachment("/fapps/oracle/fintstcomn/java/chami/test2.pdf","test2.pdf","application/pdf");
    delReq.addProperty(DeliveryPropertyDefinitions.SMTP_ATTACHMENT,m);
    Thanks

    Ok. What I needed to do is use the Bursting Engine to send out an email (list of invoices) to sales reps for our company. From what I read I have created an XML Document (Template) and have successfully ran that but it looks like I need to create a control file(bursting)? This control file would need to be saved as an XML? Is this correct?

  • Read input stream

    My function tried to parse a inputstream(xml format) but I keep getting exception: Exception org.xml.sax.SAXParseException: The root element is required in a well-formed document. I checked my XML format, it looks correct. Is there a way I can print out the input stream but still be able to parse it later with the sam input stream? Thanks.
    public static final Document getDOMTree(InputStream input) throws Exception
    try
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         DocumentBuilder builder = factory.newDocumentBuilder();
         Document doc = builder.parse(input);
    return doc;
    } catch(DOMException de) {
    System.out.println("parse error " +de);
         throw new Exception(de.toString());
    } catch(Exception e)
    System.out.println("Exception " +e);
         throw new Exception(e.toString());
    }

    Here's a class that I use for viewing outputstreams in a similar way - you can either adjust it to work as an input stream, or do a quick web search on TeeInputStream - I suspect you'll find some code.
    Cheers,
    - K
    * Copyright (c) 2001 Matthew Feldt. All rights reserved.
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided the copyright notice above is
    * retained.
    * THIS SOFTWARE IS PROVIDED ''AS IS'' AND WITHOUT ANY EXPRESSED OR
    * IMPLIED WARRANTIES.
    * TeeOutputStream.java
    * Java Examples In A Nutshell Copyright (c) 2000 David Flanagan
    * Exercise 3-7:
    * Write a subclass of OutputStream named TeeOutputStream that acts like a T
    * joint in a pipe; the stream sends its output to two different output streams,
    * specified when the TeeOutputStream is created. Write a simple test program
    * that uses two TeeOutputStream objects to send text read from System.in to
    * System.out and to two different test files.
    * @author Matthew Feldt <[email protected]>
    * @version 1.0, 02/12/2001 08:23
    import java.io.*;
    public class TeeOutputStream extends OutputStream {
        OutputStream ostream1, ostream2;
        /** sole TeeOutputStream constructor */
        public TeeOutputStream(OutputStream o1, OutputStream o2) throws IOException {
            ostream1 = o1;
            ostream2 = o2;
        public void close() throws IOException {
            ostream1.close();
            ostream2.close();
        public void flush() throws IOException {
            ostream1.flush();
            ostream2.flush();
        public void write(int b) throws IOException {
            byte[] buf = new byte[1];
            buf[0] = (byte)b;
            write(buf, 0, 1);
        public void write(byte[] b, int off, int len) throws IOException {
            ostream1.write(b, off, len);
            ostream2.write(b, off, len);
        /** test class */
        static class Test {
            public static void main (String args[]) {
                final String f1 = "tee1.out", f2 = "tee2.out";
                int ch;
                try {
                    // create a TeeOutputStream with System.out and a file
                    // as output streams
                    TeeOutputStream t1 = new TeeOutputStream(
                        System.out, new FileOutputStream(f1));
                    // create a TeeOutputStream with t1 and a second file as
                    // output streams
                    TeeOutputStream tee = new TeeOutputStream(
                        t1,    new FileOutputStream(f2));
                    // read characters from System.in and write to the tee
                    while ((ch = System.in.read()) != -1) {
                        tee.write(ch);
                    tee.close(); // close the tee
                } catch(FileNotFoundException e) {
                    System.err.println(e.getMessage());
                } catch(IOException e) {
                    System.err.println(e.getMessage());
    }

  • Buffered Input stream - data corruption

    Hi
    I'm using the following code to transfer data to a file
    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(
            new StringBuffer(path).append(part.getFileName()).toString()));
        BufferedInputStream in = new BufferedInputStream(part.getInputStream());
        while (in.available() > 0) {
          out.write(in.read());
        out.close();
        in.close();It write the image and text files properly
    But all the application based data like zip files,.doc files are getting corrupted
    How do I solve it? What is the problem with the code?
    Help pls

    What a waste of buffers that code is.
    We don't know how you might be corrupting the data
    coming in because you haven't show us what that code
    is like. All we see is part.getInputStream which is
    hardly enough to make a diagnosis.OOps
    private void writeAttachment(BodyPart part, String path) throws
          MessagingException,
          FileNotFoundException, IOException {
           //Make new dir
        new File(path).mkdirs();      
        if (this.EnsileCall)
             this.log("Ensile writing <<" + part.getFileName() + ">> of size = " + part.getSize());     
        // Write to file
        BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(
                new StringBuffer(path).append(part.getFileName()).toString()));
            BufferedInputStream in = new BufferedInputStream(part.getInputStream());
            while (in.available() > 0) {
              out.write(in.read());
        out.close();
        in.close();
    part.getInputStream() Part corresponds to a message body part in a mail(The attachment)
    I'm getting the mail attachment's input stream and writing it to a file.

  • When using URLConnection read input stream error

    hi,
    In my applet I build a URLConnection, it connect a jsp file. In my jsp file I refer to a javaBean. I send two objects of request and response in jsp to javaBean. In javabean return output stream to URLConnect. At that time a error happened.WHY???(Applet-JSP-JAVABean)
    Thanks.
    My main code:
    APPLET:(TestApplet)
    URL url = new URL("http://210.0.8.120/jsp/test.jsp";
    URLConnection con;
    con = url .openConnection();
    con = servlet.openConnection();
    con.setDoInput( true );
    con.setDoOutput( true );
    con.setUseCaches( false );
    con.setRequestProperty( "Content-Type","text/plain" );
    con.setAllowUserInteraction(false);
    ObjectOutputStream out;
    out = new ObjectOutputStream(con.getOutputStream());
    Serializable[] data ={"test"};
    out.writeObject( data );
    out.flush();
    out.close();
    //until here are all rigth
    ObjectInputStream in = new ObjectInputStream( con.getInputStream() );//happened error
    JSP:
    TestBean testBean = new TestBean ();
    testBean .execute(request, response);
    JAVABEAN:
    public void execute( HttpServletRequest request,
    HttpServletResponse response )
    ObjectInputStream in = new ObjectInputStream( request.getInputStream() );
    String direct = (String) in.readObject();
    System.out.prinltn("direct");
    ObjectOutputStream out = new ObjectOutputStream( response.getOutputStream() );
    SerializableSerializable[] data ={"answer"};
    out.writeObject( data );
    out.flush();
    out.close();
    Error detail:
    java.io.StreamCorruptedException: invalid stream header
         at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:729)
         at java.io.ObjectInputStream.<init>(ObjectInputStream.java:251)
         at TestApplet.postObjects(TestApplet.java:172)

    you have to pay attention to the sequence of opening the streams.
    The following example is: client sends a string to server, and servlet sends a response string back.
    client side:
             URL url = new URL( "http://152.8.113.149:8080/conn/servlet/test" );
             URLConnection conn = url.openConnection();   
             System.out.println( "conn: " + conn );
             conn.setDoOutput( true );
             conn.setDoInput( true );
             conn.setUseCaches( false );
             conn.setDefaultUseCaches (false);
             // send out a string
             OutputStream out = conn.getOutputStream();
             ObjectOutputStream oOut = new ObjectOutputStream( out );
             oOut.writeObject( strSrc ); 
             // receive a string
             InputStream in = conn.getInputStream();     
             ObjectInputStream oIn = new ObjectInputStream( in );
             String strDes = (String)oIn.readObject();server side
             // open output stream
             OutputStream out = res.getOutputStream();  
             ObjectOutputStream oOut = new ObjectOutputStream( out );
             // open input stream and read from client
             InputStream in  = req.getInputStream();
             ObjectInputStream oIn = new ObjectInputStream( in );
             String s = (String)oIn.readObject();
             System.out.println( s );
             // write to client
             oOut.writeObject( s + " back" ); I have the complete example at http://152.8.113.149/samples/app_servlet.html
    don't forget to give me the duke dollars.

  • Passing request of file input type to a jsp

    Hi i m using this script for file uploading the form is.... <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form action="uploadscript.jsp" name="filesForm" enctype="multipart/form-data" method="post">
    Please specify a file, or a set of files:
    <input type="file" name="userfile_parent" value="userfile_parent" >
    <input type="submit" value="submit" value="Send">
    </form> </body> </html> And i am tring to get the url on uploadscript.jsp by using String parentPath=request.getParameter("userfile_parent"); but i foud that its value is NULL it is not working what should i do to get the userfile_parent on uploadscript.jsp help me!!! Message was edited by: UDAY Message was edited by: UDAY
    avajain      
    Posts: 135
    From: Noida , India
    Registered: 5/10/06
    Read      Re: Passing response but getting NULL
    Posted: Sep 20, 2006 2:43 AM in response to: UDAY in response to: UDAY      
         Click to reply to this thread      Reply
    Use method="GET" in place of method="post" .
    Thanks
    UDAY      
    Posts: 26
    From: JAIPUR
    Registered: 8/14/06
    Read      Re: Passing response but getting NULL
    Posted: Sep 20, 2006 3:18 AM in response to: avajain in response to: avajain      
    Click to edit this message...           Click to reply to this thread      Reply
    now it is giving this error message by e.getMessage()
    [br]the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is null
    the uploadscript is this....
    http://www.one.esmartstudent.com
    can u please help me.

    Here is sample code which we have used in one of our projects with org.apache.commons.fileupload.*.
    You can find String fullName = (String) formValues.get("FULLNAMES"); at the end that gives name of file.
    <%@ page import="java.util.*"%>
    <%@ page import="java.util.List"%>
    <%@ page import="java.util.Iterator"%>
    <%@ page import="java.io.File"%>
    <%@ page import="java.io.*"%>
    <%@ page import="org.apache.commons.fileupload.*"%>
    <%@ page import="org.apache.commons.fileupload.disk.*"%>
    <%@ page import="org.apache.commons.fileupload.servlet.*"%>
    <%!     
         //method to return file extension
         String getFileExt(String xPath){ 
                   //Find extension
                   int dotindex = 0;     //extension character position
                   dotindex = xPath.lastIndexOf('.');
                   if (dotindex == -1){     // no extension      
                        return "";
                   int slashindex = 0;     //seperator character position
                   slashindex = Math.max(xPath.lastIndexOf('/'),xPath.lastIndexOf('\\'));
                   if (slashindex == -1){     // no seperator characters in string 
                        return xPath.substring(dotindex);
                   if (dotindex < slashindex){     //check last "." character is not before last seperator 
                        return "";
                   return xPath.substring(dotindex);
    %>
    <%           
    Map formValues = new HashMap();
    String fileName = "";
    boolean uploaded = false;
         // Check that we have a file upload request
         boolean isMultipart = FileUpload.isMultipartContent(request);
         //Create variables for path, filename and extension
         String newFilePath = CoeResourceBundle.getEmailProperties("FILE_UPLOAD_PATH");//application.getRealPath("/")+"temp";
         String newFileName ="";
         String FileExt = "";      
         //System.out.println(" newFilePath"+newFilePath+"/");
         //out.println(" newFilePath"+newFilePath+"<br>");
         // Create a factory for disk-based file items
         FileItemFactory factory = new DiskFileItemFactory();
         // Create a new file upload handler
         ServletFileUpload upload = new ServletFileUpload(factory);
         // Parse the request
         List /* FileItem */ items = upload.parseRequest(request);
         // System.out.println(" newFilePath"+newFilePath+"/");
         // Process the uploaded items
         Iterator iter = items.iterator();
         //Form fields
         while (iter.hasNext()) { 
         //System.out.println("in iterator");
              FileItem item = (FileItem) iter.next();
              if (item.isFormField()) { 
                   String name = item.getFieldName();
                   String value = item.getString();
                   if (name.equals("newFileName")) { 
                        newFileName = value;
                   //System.out.println("LOADING");
                   formValues.put(name,value);
              else { 
              //System.out.println("in iterator----");
                   String fieldName = item.getFieldName();
                   fileName = item.getName();
                   int index = fileName.lastIndexOf("\\");
              if(index != -1)
                        fileName = fileName.substring(index + 1);
              else
                        fileName = fileName;
                   FileExt = getFileExt(fileName);
                   String contentType = item.getContentType();
                   boolean isInMemory = item.isInMemory();
                   long sizeInBytes = item.getSize();
                   if (fileName.equals("") || sizeInBytes==0){ 
                        out.println("Not a valid file.<br>No upload attempted.<br><br>");
                   } else { 
                   // out.println("ACTUAL fileName= " newFilePath"\\"+fileName+ "<br>");
                        //File uploadedFile = new File(newFilePath+"\\", newFileName+FileExt);
                        File uploadedFile = new File(newFilePath+"/",fileName);
                        File oldFile = new File(CoeResourceBundle.getEmailProperties("FILE_UPLOAD_PATH")+"/"+fileName);
                        File oldFileApproved = new File(CoeResourceBundle.getEmailProperties("APPROVED_FILE_LOCATION")+"/"+fileName);
                        try{ 
                             if (!oldFile.exists()&&!oldFileApproved.exists())
                                  item.write(uploadedFile);
                                  uploaded = true;
                             //out.println(fileName+" was successfully uploaded as "+ newFileName+FileExt +".<br><br>");
                        catch (java.lang.Exception e) { 
                             out.println("Errors prevented the file upload.<br>"+fileName+ " was not uploaded.<br><br>");
         String userid = (String) formValues.get("USERID");
         String fullName = (String) formValues.get("FULLNAMES");
         String email = (String) formValues.get("EMAILID");
         String empno = (String) formValues.get("EMPNO");
         String docType = (String) formValues.get("DOCTYPE");
         String desc = (String) formValues.get("MYTEXT");
         String title = (String) formValues.get("TITLEBOX");
         String module = (String) formValues.get("MODULE");
         String techfunctype = (String) formValues.get("TECHFUNCTYPE");
    %>

Maybe you are looking for

  • Adding Classes to the JAR File's Classpath

    Ques 1- Can I use the wildcard * symbol in Manifest file to add classes/othes jar files to the JAR File's Classpath.I have folder named - Lib . where there are many jar files.Now,do I have to add each jar file by- Class-Path: Lib/jar1-name Lib/jar2-n

  • Family Base Not Restricting After Hours

    We have Family Base installed on our phone and on our son's phone. We have night time hours set up - but Family Base is not restricting his text messages or anything. Could this be because he has Wi-fi and mobile data turned off? How is he getting ar

  • DataMart Interface - Date and time of the transferred data

    Hello, We have a requirement to build a datamart (cube to cube) between two BW systems, using deltas; this is OK and should not present any issue. However a further requirement has arisen, requiring to provide date and time of the created files to ou

  • Have lost my playlist "recently added"

    Not sure how, but I seemed to have lost the playlist "recently Added" from my left hand side playlists, which was always very useful to me. Any ideas how to get it back? Thanks

  • Data reduction - setting factor in program

    Is there a possibility to set the data reduction factor of the data reduction Express VI in the program and not only in the settings of the Express VI itself ?