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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:09:44+00:00 2026-06-15T15:09:44+00:00

I use wicket in my webapplication. I save the Strings in some .properties files

  • 0

I use wicket in my webapplication. I save the Strings in some .properties files as follows:

foo.properties

page.label=dummy

In the html-file, I can acces the String page.label as follows:

index.html

<wicket:message key="page.label">Default label</wicket:message>

Now I wrote some junit test cases for my Application and would like to access the Strings saved in the properties file. My Question is, how to read the String from the properties file?

  • 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-15T15:09:45+00:00Added an answer on June 15, 2026 at 3:09 pm

    Try this

    import java.io.FileInputStream;
    import java.util.Properties;
    
    public class MainClass {
      public static void main(String args[]) throws IOException {
        Properties p = new Properties();
        p.load(new FileInputStream("foo.properties"));
        Object label = p.get("page.label");
        System.out.println(label);
      }
    }
    

    This section allow you to read all properties files from wherever you want and load them in the Properties

    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.net.URISyntaxException;
    import java.net.URL;
    import java.net.URLClassLoader;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Properties;
    
    public class MainClass {
    
        private static String PROPERTIES_FILES_PATHNAME = "file:///Users/ftam/Downloads/test/";// for mac
    
        public static void main(String args[]) throws Exception {
            Properties p = new Properties();
    
            List<File> files = getFiles();
            for(File file : files) {
                FileInputStream input = new FileInputStream(file);
                p.load(input);
            }
    
            String label = (String) p.get("page.label");
            System.out.println(label);
        }
    
        private static List<File> getFiles() throws IOException, URISyntaxException {
            List<File> filesList = new ArrayList<File>();
    
            URL[] url = { new URL(PROPERTIES_FILES_PATHNAME) };
            URLClassLoader loader = new URLClassLoader(url);
            URL[] urls = loader.getURLs();
    
            File fileMetaInf = new File(urls[0].toURI());
            File[] files = fileMetaInf.listFiles();
            for(File file : files) {
                if(!file.isDirectory() && file.getName().endsWith(".properties")) {
                    filesList.add(file);
                }
            }
    
            return filesList;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I use recaptcha with apache wicket 1.5.3? Is there some good example?
I'm trying to use an image for a link like so: <wicket:link> <a href=UploadPage.html>
In my wicket app, I want to use my own converter for some textfields
Just to mention, I use Wicket to implement this program. I have a html
I use Wicket framework and I would like to know if there is a
I want to create a web app that will use wicket, hibernate and spring
use C#,want to upload excel file on google doc. bellow syntax use to upload
Use of gradient images is very common among developers for styling a page. Gradient
I'm looking for an easy-to-use and intergrate ORM for Wicket application. I was thinking
I am pretty new to Wicket and i have some difficulties with using resource

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.