Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 381431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:05:05+00:00 2026-05-12T15:05:05+00:00

I am creating filenames based on dynamic values such as company name and forename/surname.

  • 0

I am creating filenames based on dynamic values such as company name and forename/surname.

I would then like to verify that the filename is valid before attempting to create the file. That is check it doesn’t contain any illegal characters, and replace them if they do.

I could of course just use a regular expression, but was wondering if there was an existing method in something like commons-lang or commons-io that does this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:05:06+00:00Added an answer on May 12, 2026 at 3:05 pm

    With Java 7, the new method java.nio.file.Paths.get(String path) will throw an InvalidPathException if the path contains illegal characters for the specific file system, but in Java 6 or earlier, there is unfortunately no such function.

    Since the allowed characters in and length of a file name are highly platform (or even file system) dependent, you might have no better option than to try to create the file and see if it fails. In Java 6, creating a FileOutputStream with an illegal path will throw a rather unspecific FileNotFoundException.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently creating a directory based on file names and then moving the
I have a list of files I would like to sort based on the
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
Error creating bean with name 'sessionFactory' defined in class path resource [ApplicationContext.xml]: Invocation of
I'm having trouble creating the upload mechanism for a custom field based on: libraries/joomla/filesystem/file.php.
Currently am creating files using the below code,I want to create a directory based
I am creating a class, then trying to do some operations inside it, but
I'm creating a tool that is supposed to concatenate docs that contain the same
I'm creating PDF invoices in a C# MVC application that I'm attaching to an
I am a beginner to Visual Studio C++. I am creating a dialog based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.