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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:25:19+00:00 2026-05-22T12:25:19+00:00

I have csv files stored on my server. If I enter the right key

  • 0

I have csv files stored on my server. If I enter the right key (which is a part of URL) I get what I want, but if the entered key was wrong my app crashes. I want to be able to catch the error.

    String url="http://mysite.com/template";
            url=url+et.getText().toString().toLowerCase()+".csv";

            csv.setURL(url);
            if(csv.checkURL()){
                enterToDB();

            }
            else{
                tv.setText("Wrong key");
            }       

and my CSVReader looks like:

 public void setURL(String file){

     try {
        URL url = new URL(file);
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    success=true;
        in.close();
    } catch (MalformedURLException e) { success=false;} catch (IOException e) {  success=false;     }
   }

public boolean checkURL(){
    return success;
}

  }
  • 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-22T12:25:20+00:00Added an answer on May 22, 2026 at 12:25 pm

    Without the complete minimal code necessary to replicate the problem, and without information about what the specific error is (like a stack trace), I’m just guessing that the setURL/checkURL routines don’t exactly do what you want. They appear to assume that openStream will throw an exception if the key in the URL is wrong, but that’s not the case. Even if the path or key in the URL is wrong, the HTTP server will still provide a response. The response might not be 200 OK and the response body might not include what you’re looking for, but it’ll still give a response, and the open stream can be used to read the response.

    So, if I understand correctly, you actually want to inspect the contents of the response (including probably the HTTP status code), before deciding whether the “success” is true or false.

    Thane posted some code I gave him over in How should I handle server timeouts and error code responses to an http post in Android App?. I recommend reviewing it and seeing if it provides the structure you need to handle successful and failed responses accordingly.

    Making sense?

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

Sidebar

Related Questions

I have a large CSV file and I want to execute a stored procedure
I have to read CSV files line by line which can be 10 to
I have a set of 10 CSV files, which normally have a an entry
I have a VB application which extracts data and creates 3 CSV files (a.csv,
I have thousands of small CSV files I want to aggregate (with a little
I have a set of data stored in text files, which I have now
I have several large csv files with thousands of columns that I need to
I have a large collection of data in an excel file (and csv files).
I have two DataTables, A and B , produced from CSV files. I need
I have a bunch of pretty large CSV (comma separated values) files and I

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.