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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:41:06+00:00 2026-06-04T22:41:06+00:00

I have a properties file {Content} com.some.that.file.txt = com.some.dest com.fold.cust.dir = com.some.dest Where the

  • 0

I have a properties file

{Content}
com.some.that.file.txt = com.some.dest
com.fold.cust.dir = com.some.dest

Where the key denotes the name of a directory to copy to {Value}=com.some.dest

I have replaced dots with “/” but with this i cannot retain the filename e.g file.txt becomes file/txt.

  • 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-06-04T22:41:08+00:00Added an answer on June 4, 2026 at 10:41 pm

    Use String.replaceAll(regex, replacement) with the right regex:

    String filename = value.replaceAll("\\.(?=.*\\.)", "/");
    

    This regex matches dots, but only if there’s another dot somewhere after the matched dot, checked using a “look ahead”, which has syntax (?=regex).

    Here’s a test:

    public static void main(String[] args) {
        String value = "com.some.that.file.txt";
        String filename = value.replaceAll("\\.(?=.*\\.)", "/");
        System.out.println(filename);
    }
    

    Output:

    com/some/that/file.txt
    

    Edited:

    To find the directory names, use this:

    String dirname = filename.replaceAll("/(?!.*/).*", "");
    

    or in one line:

    String dirname = value.replaceAll("\\.(?=.*\\.)", "/").replaceAll("/(?!.*/).*", "");
    

    This extra step uses a “negative look ahead”, which has syntax (?!regex), to match a slash only if there isn’t a slash somewhere after the matched slash and then the regex matches everything after that using .*

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

Sidebar

Related Questions

I have an f:loadBundle that loads a properties file from my classpath. <f:loadBundle basename=com.xxx.ui.messages
I have a properties file, let say my-file.properties. In addition to that, I have
I have a shared properties file shared.properties.proj <Project xmlns=http://schemas.microsoft.com/developer/msbuild/2003> <PropertyGroup> <SharedAssemblySearch>$(MSBuildProjectDirectory)\..\Shared Assemblies</SharedAssemblySearch> <ParentDir>..</ParentDir> <SharedAssemblySearch
I have an executable jar Client.jar that requires jndi.properties file. Since the jndi properties
I have a java app, and the log4j.properties file is in src/com/my/path/props. On compile,
I have some code that is reading a config file, but when I open
I have a properties file which currently contains system names and ip addresses. What
I have properties in the .h file and synthesized in .m file, I know
I have the following log4j.properties file: log4j.rootLogger=DEBUG,A1,A2,A3 log4j.appender.A1=org.apache.log4j.RollingFileAppender log4j.appender.A1.Threshold=DEBUG log4j.appender.A1.File=log.out log4j.appender.A1.MaxFileSize=100KB log4j.appender.A1.MaxBackupIndex=1 log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%p
I have configured the loading of the properties file as shown below (Spring 3.1)

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.