I'm getting "There is no space left on disk" message when i try to do some
work on the server after this 0 byte files are created

On Fri, Jul 2, 2010 at 1:13 PM, Pid <p...@pidster.com> wrote:

> On 02/07/2010 11:01, Murat Birben wrote:
> > Yes 0 byte files are causing the disk to run out of space
>
> You understand my surprise?
>
> Are you sure the disk is running out of space, or is it that the number
> of files permitted in a directory has been exceeded?
>
>
> p
>
>
> > @Andre Warnier
> > I'm not actually saving files on the server. I just tried to simplify my
> > problem and tried that simple code. Now i'll give a try to apache
> > fileupload api, thanks for advice
> >
> > On Fri, Jul 2, 2010 at 11:52 AM, Pid <p...@pidster.com
> > <mailto:p...@pidster.com>> wrote:
> >
> >     On 02/07/2010 09:43, Murat Birben wrote:
> >     > Hi all,
> >     >
> >     > I have a very simple file upload mechanism in java. I just take
> >     the file and
> >     > save it on the server. I'm testing this simple code with selenium
> >     and *when
> >     > a timeout occurs in the selenium test *tomcat creates 0 byte files
> >     under
> >     > tomcat_home/work/Catalina/localhost/uploadServlet/ directory as
> >     MultiPart*
> >     > files. It creates thousands of files, until there is no disk space
> >     left on
> >     > device. What may cause this problem? How can I solve this? Is
> >     there anyone
> >     > has an idea about this?
> >
> >     Thousands of 0 byte files are causing the disk to run out of space?
> >
> >
> >     p
> >
> >     > My environment is: Ubuntu - 8.04 server, apache tomcat - 5.5.29,
> >     sun java
> >     > 1.6
> >     >
> >     > Thanks,
> >     >
> >     > Here is the code snippet that i use
> >     >
> >     >         File fFile = null;
> >     >         FileOutputStream fileOutputStream = null;
> >     >         FileInputStream fileInputStream = null;
> >     >         try {
> >     >
> >     >             String strFileName = request.getParameter("FileName");
> >     >             String strPath = request.getParameter("Path");
> >     >             //String strMediaType =
> request.getParameter("MediaType");
> >     >
> >     >             //String strDescription =
> >     request.getParameter("Description");
> >     >             fFile = (File) request.getAttribute("Content");
> >     >
> >     >             int index = strPath.length() - 1; //If the user forgets
> to
> >     > put the last / for the path... We put it for him/her
> >     >
> >     >             if (strPath.charAt(index) != '/') {
> >     >                 strPath += "/";
> >     >             }
> >     >             if (!new File(strPath).exists()) {
> >     >                 new File(strPath).mkdirs();
> >     >             }
> >     >
> >     >             File file = new File(strPath + strFileName);
> >     >             fileOutputStream = new FileOutputStream(file);
> >     >             fileInputStream = new FileInputStream(fFile);
> >     >
> >     >             byte[] bBuf = new byte[1024];
> >     >
> >     >             int iBufLen = 0;
> >     >             int iReadLen = 1024;
> >     >             int iTotelLen = 0;
> >     >             /*read 1024 bytes at a time*/
> >     >             while ((iBufLen = fileInputStream.read(bBuf)) != -1) {
> >     >
> >     >                 fileOutputStream.write(bBuf);
> >     >                 fileOutputStream.flush();
> >     >                 iTotelLen += iBufLen;
> >     >                 if (fileInputStream.available() < iReadLen) {
> >     >                     iReadLen = fileInputStream.available();
> >     >
> >     >                     break;
> >     >                 }
> >     >             }
> >     >
> >     >             byte[] tempbBuf = new byte[iReadLen];
> >     >             fileInputStream.read(tempbBuf, 0, iReadLen);
> >     >
> >     >             fileOutputStream.write(tempbBuf);
> >     >
> >     >
> >     >         } catch (IOException ex) {
> >     >             ex.printStackTrace();
> >     >         } finally {
> >     >             fileOutputStream.close();
> >     >             fileInputStream.close();
> >     >
> >     >             if (fFile.exists()) {
> >     >
> >     >                 fFile.delete();
> >     >             }
> >     >         }
> >     >
> >     >
> >     >
> >
> >
> >
> >
> >
> > --
> > Murat BIRBEN
>
>
>


-- 
Murat BIRBEN

Reply via email to