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

  • Home
  • SEARCH
  • 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 8151399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:22:34+00:00 2026-06-06T15:22:34+00:00

Ok, I thought this would be simpler but I was probably wrong.. My parser

  • 0

Ok, I thought this would be simpler but I was probably wrong..
My parser works fine (directly with the connection works) so I’ve some BASIC problems with writing and reading a file on Android (aka Java) or with Input/Output Stream..
The problem is that I don’t know what’s not working.. I’m missing any permission? I’m missing something while writing or reading the file?

Here is the code:

            URL url = new URL(urlXml);

            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();
            XMLReader reader = sp.getXMLReader();

            CustomXmlHandler handler = new CustomXmlHandler();
            reader.setContentHandler((ContentHandler) handler);


            String fileName = getFileName();
            File f = getFileStreamPath(fileName);

            if(!f.exists()) {
                FileOutputStream fos = openFileOutput(fileName, Context.MODE_PRIVATE);                  
                URLConnection conn = url.openConnection();
                conn.setConnectTimeout(5000);
                conn.setReadTimeout(10000);
                InputStream in = conn.getInputStream();             
                byte[] buffer = new byte[1024];
                int len = 0;
                while((len = in.read(buffer)) != -1) {
                    fos.write(buffer, 0, len);
                }
                fos.close();
                in.close();
            }
            FileInputStream fis = openFileInput(fileName);
            reader.parse(new InputSource(new InputStreamReader(fis)));
            fis.close();
            myObject = handler.getMyObject();

Thanks in advance.. I’m getting crazy..

  • 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-06T15:22:36+00:00Added an answer on June 6, 2026 at 3:22 pm

    Actually this code it’s fine. The error was somewhere else.

    I’ll leave the code here for someone else that is looking for something similar!

    If I shouldn’t just tell me and I’ll remove it. 🙂

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

Sidebar

Related Questions

OK so I thought this would be pretty simple but it's tripping me up..
I thought this would be fairly easy, but I'm totally baffled. I want one
I thought this would be pretty easy but I'm running into all sorts of
Okay at first I thought this would be pretty straightforward. But I can't think
I've been reading through regex and I thought this would work but it doesn't
This probably has probably been asked before, but I couldn't find anything relevant. Would
I know there is probably no simple way to do this, but I thought
I thought this would be simple, but I sure am having a lot of
This is probably a really simple question but... I would like to do a
Sorry, this looks longer than it probably is but I thought I should include

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.