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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:42:42+00:00 2026-05-27T10:42:42+00:00

Currently, I can only make my app access to the XML database when the

  • 0

Currently, I can only make my app access to the XML database when the jar file and XML file in the same directory, and what I hope is that there is only one single jar file which includes the XML file. How can I do that?

private String getXmlPath() {
    String url = "";
    try {
        String cp = "Data\\QuestionList.xml";
        File f = new File(ClassLoader.getSystemResource("\\").toURI().getPath());
        url += f.getPath() + "\\" + cp;
    } catch (URISyntaxException ex) {  
        url="QuestionList.xml";
    }
    System.out.println(url);
    return url;
}

public void classifyQuestionnaire(String path)
        throws FileNotFoundException, XMLStreamException, JAXBException {
    // Parse the data, filtering out the start elements
    XMLInputFactory xmlif = XMLInputFactory.newInstance();
    FileReader fr = null;
    if (path == null) {
        fr = new FileReader(getXmlPath());
    } else {
        fr = new FileReader(path);
    }
    XMLEventReader xmler = xmlif.createXMLEventReader(fr);
    EventFilter filter = new EventFilter() {

        @Override
        public boolean accept(XMLEvent event) {
            return event.isStartElement();
        }
    };
  • 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-27T10:42:43+00:00Added an answer on May 27, 2026 at 10:42 am

    You can include xml file into the jar. These non-class files are usually called “resource”. It depends on how you’re creating the jar, but it’s usually straight forward. See Java: Load a resource contained in a jar for reading the resource.

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

Sidebar

Related Questions

I can currently use sgml-pretty-print to pretty print an xml file in emacs, but
Currently only the Table Id can be used which is meaningless as it is
I created a C#.net app that uses dates from a SQL Server 2008 database
For an access database that looks like this: (All text fields) Co1 Co2 Co3
Currently I make a twitter app for android. I want to get user's home
We're trying to make an iOS app that allows users to create geographical points
I'm writing a database access app for storing some data and want to ask
I have a Cocoa document-based app that (currently at least) functions as a basic
Currently In my embedded linux I can not open multiple ALSA sound stream. What
How can I check the umask of a program which is currently running? [update:

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.