Solved

how tp get just the extension of a file

Posted on 2006-07-21
1
175 Views
Last Modified: 2010-04-01
Hi I have this code

file_name = form_file_input.getName();
file_size = (int) form_file_input.getSize();
file_type = form_file_input.getContentType();

Now form_file_input.getContentType(); gets this value application/vnd.ms-excel for an excel file
but what I need is to get .xls so that I can add this .xls to the filename when I am saving the file.

Any help will be greatly appreciated



0
Comment
Question by:huzefaq
1 Comment
 
LVL 12

Accepted Solution

by:
enachemc earned 500 total points
ID: 17154481
String fn = form_file_input.getFileName();
int posPoint = fn.lastIndexOf('.');
String ext = null;
if(posPoint > 0){
    ext = fn.substring(posPoint + 1);
}
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
library class in java 1 93
Handle form fields in spring mvc controller 1 66
How to find missing packages when using Netbeans IDE 8.1 ? 19 59
login jsp example 24 69
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Ransomware continues to grow in reach and sophistication, putting data everywhere at risk. Learn how to avoid being caught in its sinister clutches with these 11 key tips.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question