Servlets.com

Home

What's New?

com.oreilly.servlet

Servlet Polls

Mailing Lists

List Archives

Servlet Engines

Servlet ISPs

Servlet Tools

Documentation

Online Articles

The Soapbox

"Java Servlet
Programming,
Second Edition"

"Java Enterprise
Best Practices"

Speaking & Slides

About Jason

XQuery Affiliate

Advertising Info

DefaultFileRenamePolicy

com.oreilly.servlet.multipart
Class DefaultFileRenamePolicy


java.lang.Object
  |
  +--com.oreilly.servlet.multipart.DefaultFileRenamePolicy
All Implemented Interfaces:
FileRenamePolicy

public class DefaultFileRenamePolicy
extends java.lang.Object
implements FileRenamePolicy

Implements a renaming policy that adds increasing integers to the body of any file that collides. For example, if foo.gif is being uploaded and a file by the same name already exists, this logic will rename the upload foo1.gif. A second upload by the same name would be foo2.gif. Note that for safety the rename() method creates a zero-length file with the chosen name to act as a marker that the name is taken even before the upload starts writing the bytes.

Version:
1.1, 2002/11/05, making thread safe with createNewFile()
, 1.0, 2002/04/30, initial revision, thanks to Yoonjung Lee for this idea
Author:
Jason Hunter

Constructor Summary
DefaultFileRenamePolicy()
           
 
Method Summary
 java.io.File rename(java.io.File f)
          Returns a File object holding a new name for the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFileRenamePolicy

public DefaultFileRenamePolicy()
Method Detail

rename

public java.io.File rename(java.io.File f)
Description copied from interface: FileRenamePolicy
Returns a File object holding a new name for the specified file.

Specified by:
rename in interface FileRenamePolicy
See Also:
FilePart.writeTo(File fileOrDirectory)

 


Home   com.oreilly.servlet   Polls   Lists   Archives
Engines   ISPs   Tools   Docs   Articles   Soapbox   Book

Copyright © 1999-2005 Jason Hunter
Privacy Policy

webmaster@servlets.com
Last updated: October 30, 2006