Solved

how tp get just the extension of a file

Posted on 2006-07-21
1
172 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A procedure for exporting installed hotfix details of remote computers using powershell
In  today’s increasingly digital world, managed service providers (MSPs) fight for their customers’ attention, looking for ways to make them stay and purchase more services. One way to encourage that behavior is to develop a dependable brand of prod…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now