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 1011353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:13:14+00:00 2026-05-16T09:13:14+00:00

In my properties file I have one property, which contains a comma separated list

  • 0

In my properties file I have one property, which contains a comma separated list of values

In my code, I would like to load that property in, split it from the commas, and add each value into an array. I also want to make sure I don’t have values in the array due to whitespace etc

example property :

prop_allowed_extensions = .jpeg,tiff, .txt 

I have come up with this so far, but it feels dirty, is there a more elegant solution?

String test = classProperties.getProperty("prop_allowed_extensions", "txt, jpeg");
String[] splitString = StringUtils.split(test, ',');
String[] newString = new String[splitString.length];             
for (int i = 0; i < splitString.length; i++)
{
   newString[i] = StringUtils.trim(splitString[i]);                
}

I just want the text of the file extension, would it be appropriate to use a regular expression to remove whitespace/non-letters?

  • 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-16T09:13:15+00:00Added an answer on May 16, 2026 at 9:13 am

    You can do it in two steps:

    String[] allowedExtensions = str.replaceAll("[^\\w,_]", "").split(",")
    

    (First kill anything that is not either a comma, an underscore or a word character (letter or digit), then split the resulting string

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

Sidebar

Related Questions

I have a properties file which currently contains system names and ip addresses. What
I have a file called messages.properties which has lines with syntax <key>=<string> . Each
I have a boolean setting in my Properties/Settings.settings file, which basically stores per user
On JBoss 5.0.1 I have configured the deploy/properties-service.xml to reference a properties file like
Say I have a config file in which I have paths to JSON properties.
I have a class with many properties, one of them are byte[] property. I
Basically, I have to overwrite a certain property in a .properties file through a
I have this method signature: List<ITMData> Parse(string[] lines) ITMData has 35 properties. How would
I have an ICEfaces web app which contains a component with a property linked
I have a properties file, let say my-file.properties. In addition to that, I have

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.