Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

Generic file name validation code?

Thread view: 
harry - 02 Sep 2007 12:15 GMT
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
Roedy Green - 02 Sep 2007 12:40 GMT
>Does anybody know of java code that does this?

If you limited the name to A-Z a-z 0-9 . it would work on anything
without a tight length limit anything.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

harryajh - 02 Sep 2007 12:57 GMT
> >Does anybody know of java code that does this?
>
[quoted text clipped - 3 lines]
> Roedy Green Canadian Mind Products
> The Java Glossaryhttp://mindprod.com

Thanks Roedy, this seems to do the job (forgot to say file name must
end with "con")

       Pattern p = Pattern.compile("([A-Z]|[a-z]|[0-9])+.con");
Arne Vajhøj - 02 Sep 2007 15:14 GMT
>>> Does anybody know of java code that does this?
>> If you limited the name to A-Z a-z 0-9 . it would work on anything
[quoted text clipped - 4 lines]
>
>         Pattern p = Pattern.compile("([A-Z]|[a-z]|[0-9])+.con");

That can be abbreviated to:

Pattern p = Pattern.compile("([A-Za-z0-9])+.con");

Arne
Eric Sosman - 02 Sep 2007 15:40 GMT
>>> On Sun, 02 Sep 2007 11:15:34 GMT, "harry" <a...@abc.com> wrote,
>>> quoted or
[quoted text clipped - 11 lines]
>
> Pattern p = Pattern.compile("([A-Za-z0-9])+.con");

    Better quote that . character ...  Also, the ( ) can be
eliminated if the O.P. doesn't need the capturing group.

Signature

Eric Sosman
esosman@ieee-dot-org.invalid

Arne Vajhøj - 02 Sep 2007 21:49 GMT
>> >         Pattern p = Pattern.compile("([A-Z]|[a-z]|[0-9])+.con");
>>
[quoted text clipped - 3 lines]
>
>     Better quote that . character ...

Yes.

Arne
Stefan Ram - 02 Sep 2007 19:57 GMT
>>Does anybody know of java code that does this?
>If you limited the name to A-Z a-z 0-9 . it would work on anything
>without a tight length limit anything.

 The library »ram.jar« contains code to convert any
 Unicode-Text (including surrogate pairs) into a text
 consisting only of uppercase letters and numbers
 that can be used as a file name under most
 file systems as long as it is short enough.

public final class Main
{ public static void main( final String[] args )
 {
   final java.lang.String text =
   "¿Aren't Kafka's Schloß and Æsops oeuvres often naïve?";

   final java.lang.String product =
   de.dclj.ram.notation.filode.Text.sourceText( text );

   java.lang.System.out.println( product ); }}

XBFZYARENXNTXGYKAFKAXNSXGYSCHLOXDFZXGANDXGXC6ZSOPSXGOEUVRESXGOFTENXGNAXEFZVEXK

 The encoding used is called »Filode« and being described
 on the Filode homepage

http://www.purl.org/stefan_ram/pub/filode

 The ram.jar homepage:

http://www.purl.org/stefan_ram/pub/ram-jar


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.