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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:08:37+00:00 2026-06-05T18:08:37+00:00

I have to import data from an Excel file to database and to do

  • 0

I have to import data from an Excel file to database and to do this, I would like to check the extension of the chosen file.

This is my code:

String filename = file.getName();
String extension = filename.substring(filename.lastIndexOf(".") + 1, filename.length());

String excel = "xls";
if (extension != excel) {
    JOptionPane.showMessageDialog(null, "Choose an excel file!");
}
else {
    String filepath = file.getAbsolutePath();
    JOptionPane.showMessageDialog(null, filepath);
    String upload = UploadPoData.initialize(null, filepath);

    if (upload == "OK") {
        JOptionPane.showMessageDialog(null, "Upload Successful!");
    }
}

But I always get:

Choose an excel file!

I can’t find what is wrong with my code, could someone please help.

  • 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-05T18:08:39+00:00Added an answer on June 5, 2026 at 6:08 pm

    following

    extension != excel
    

    should be

    !excel.equals(extension)
    

    or

    !excel.equalsIgnoreCase(extension)
    

    See also

    • String equals() versus ==
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have few text and excel file, from which I need to import data
I have written a database app that imports data from an excel file into
I have an Excel file (which has data imported from Oracle 10G Database) one
I have simple SSIS package where I import data from flat file into SQL
I have a problem using the SSIS. I try to import data from database
I have setup a database view. When users import the data from the view
I have a large nested vector that look like this: import Data.Vector let x
I want to import data from an Excel file - assume Excel 2003 /
I need to make an excel file which would fetch data from connection to
I want to import data from Excel worksheet into SQL Server database (2008). 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.