Generic file name validation code? - Java

This is a discussion on Generic file name validation code? - Java ; I need to validate a file name but it has to work on Windows & Unix! Does anybody know of java code that does this? thanks in advance harry...

+ Reply to Thread
Results 1 to 3 of 3

Generic file name validation code?

  1. Default Generic file name validation code?

    I need to validate a file name but it has to work on Windows & Unix!

    Does anybody know of java code that does this?

    thanks in advance

    harry



  2. Default Re: Generic file name validation code?

    harry wrote:
    > I need to validate a file name but it has to work on Windows & Unix!
    >
    > Does anybody know of java code that does this?
    >
    > thanks in advance
    >
    > harry
    >
    >

    This sounds easy to write using the java.util.regex package.
    How should a file name look like ?

  3. Default Re: Generic file name validation code?

    harry <a@abc.com> wrote:
    >I need to validate a file name but it has to work on Windows & Unix!


    What's "it" in that sentence? The code or the filename? It's very easy to
    make the code work in multiple OSs, of course. It's very hard to make a
    perfect validator to ensure that a filename would be valid in, say, the
    Japanese release of Windows 95 when running under Solaris with an 8859-1
    default encoding.

    >Does anybody know of java code that does this?


    java.io.File forces some amount of well-formedness, and getCanonicalFile()
    will normalize it using OS-specific code. If you try to actually create or
    read the file, you'll be certain that the path is valid.

    You won't know if it would be valid on another OS, but you really can't
    know that anyway - different paths, drive letter conventions, permissions,
    conflicting files, etc, even on the same OS on another machine will break.
    --
    Mark Rafn dagon@dagon.net <http://www.dagon.net/>

+ Reply to Thread

Similar Threads

  1. Generic way of writing this enum code?
    By Application Development in forum CSharp
    Replies: 4
    Last Post: 10-31-2007, 03:38 AM
  2. Generic file name validation code?
    By Application Development in forum Java
    Replies: 6
    Last Post: 09-02-2007, 03:49 PM
  3. Force a TextBox validation in code?
    By Application Development in forum CSharp
    Replies: 1
    Last Post: 08-22-2007, 09:11 AM
  4. converting some generic java code to .net
    By Application Development in forum CSharp
    Replies: 0
    Last Post: 08-15-2007, 03:39 PM
  5. Checking against null in generic code
    By Application Development in forum DOTNET
    Replies: 5
    Last Post: 07-24-2007, 01:20 PM