How can I get a filename without the file extension?

I using a JFileChooser to select and read a file. Now I want to get the filename without the file extension
JFileChooser j = new JFileChooser;
String file = j.getSelectedFile.getName();
At the moment I get this result "file.dat". I need only the filename.....
Thank you
Thomas

It's quite that.
Here is the code to do that (and the method to get only the extension):
     public String getFileName(String text) {
          int ind = text.lastIndexOf(".");
          if(0<ind && ind<(text.length()-1)) {
               return text.substring(0, ind);
          return(null);
     public String getFileExtension(String text) {
          int ind = text.lastIndexOf(".");
          if(0<ind && ind<(text.length()-1)) {
               return text.substring(ind+1).toLowerCase();
          return(null);
     }(I used 0<ind instead of ind>0 because with the code formatting there is a bug with > )
I hope this helps,
Denis

Similar Messages

  • How can I get Thumbnails back in the file View Menu?

    My computer died and I had to re-install CS6.  I had originally installed it to an external hard drive expecting that I could just hook up a new computer when the time came and everything would work as before.   Not to be.   I contacted Adobe and got the program re-installed.  Now, when I open a file, I am unable to change the view in the View Menu to 'thumbnail' because 'thumbnail' is no longer an option.  How can I get that option back?
    Thank you.

    Are you talking about in the File>Open dialog in photoshop cs6?
    Could you post screenshot of what you see?
    Windows 7 doesn't have a thumbnail option as windows xp, but you should be able to at least see the jpeg thumbnails without any third party programs.
    If you pick Tiles or one of the three Icon options at the top, your not able to see the jpeg thumbnails?

  • How can I get Firefox to recognize ODM file extensions? Help! bmathias@usf.edu

    Windows7, Firefox version? (not sure what version! it doesn't come up under Properties!) but my computer was just upgraded to Windows7 last week & Firefox reinstalled, so probably the latest version. OverDrive (ODM file extensions) is a DRM software system used by public libraries to limit checkout/access of streamed audio & e-books. But the audiobooks won't download. The troubleshooting directions say that I shoule be able to find the ODM file extension under Tools -- Options -- Applications in Firefox. But it isn't listing. Perhaps this is why the download doesn't work? How do I get Firefox to work with ODM file extension?

    Check the URL that doesn't work.
    ''If it is an http:// URL:''
    When a web server sends Firefox a file, it includes a content-type header. This is what Firefox uses to determine how to handle the file, not the file extension. The server might be sending a generic download type such as "application/octet-stream" which you cannot assign to any one application. That's just a guess because I don't use that software.
    ''If it is an st:// URL:''
    Firefox will check the Windows registry for novel protocols. This article has more information: http://kb.mozillazine.org/Register_protocol

  • How can I get a date without the hour from sql server 2000 ?

    hellou!
    I have a JTable, and one of it's columns has to show a date. This date i have to show is specified as datetime on the Sql Server 2000 database where I have to take the data.
    the query of the dataset attached to the JTable is something like "select * from Table".
    The problem is that the JTable column that displays the date shows the date and the hour, for example:
    7/10/04 0:00:00
    and I need to show the date without the hour, only the 7/10/04. Can anyone tell me how to do that?
    thank you very much! : )

    The easiest way to format a date is with java.text.SimpleDateFormat. When creating it you pass a format string which can be used to parse or format date objects.
    SimpleDateFormat formater = new SimpleDateFormat( "MM/dd/yyyy" );
    // Get date objects directly from sql
    Date foundDate = result.getDate( 1 );  //where result is the ResultSet and 1 is the date column
    String formatedDate = formater.format( foundDate );Now the JTable's table model can be adjusted to store a formated String instead of a Date. If for some reason it is required to store the value as a Date overload the table model to return the formated string when getValueAt is called.

  • Getting rid of PSE7 trial, how can I get rid of all the files?

    I'm trying to get an older version of PSE on my pc, but since Ihad the  trail of PSE7 on it, there's still some files around on my computer that is stopping me from getting my old one back, and since the trial has long-since expired I'm stuck without an art program to work with.
    Someone told me there should be a utility program on the site... But I have yet to find it.

    Type regedit in  your Vista search bar.  You'll have to type the entire word before it shows up in the program list. Double click it when it shows up in the programs list to open as any other application.  Be sure you back up your registry before tinking with anything.
    Articles that might be useful:
    http://pcsupport.about.com/od/windowsvista/ht/backupvistareg.htm
    Note: There are several related links...how to restore the windows registry, etc...at the above site.
    Other articles that you may find useful...
    http://www.informit.com/articles/article.aspx?p=1151313
    http://www.computerperformance.co.uk/vista/vista_registry.htm
    The above site also has related links like the one below that may be of use.
    http://www.computerperformance.co.uk/vista/vista_registry_tips.htm

  • HT1727 i bought some ringtones on my iPhone, later on i sync my iphone to my old computer now i have a new mac pro desktop and i only have 2 ringtones on my phone but not the rest of them how can i get them back without having to pay for them again?

    i bought some ringtones on my iPhone, later on i sync my iphone to my old computer now i have a new mac pro desktop and i only have 2 ringtones on my phone but not the rest of them how can i get them back without having to pay for them again?

    If you bought them on your iPad then you will need to connect your iPad to your computer's iTunes and do File > Devices > Transfer Purchases to copy them over to the Tones part of your computer's iTunes library and you can then sync them to your iPhone - ringtones are a one-time only download, so you won't be able to redownload them directly on your phone.

  • HT1420 I purchased and downloaded and album of ten songs. most of the songs cut out after several seconds. How can I get them again without having to re-purchase???

    I purchased and downloaded and album of ten songs. most of the songs cut out after several seconds. How can I get them again without having to re-purchase???

    Delete the problem song(s) from library including file(s). Then go to the iTunes Store and select "Purchased" from the Quick Links side bar on the right. Select Music tab to re-download again for free.

  • How can I get iTunes to display the tracks from a CD in their original (album) order?

    To be absolutely honest, I don't really understand what this box is for, so I shall just use it to repeat and expand on my question. (I have already sent a "Feedback" comment on the same topic).
    How can I get iTunes to display the tracks from a CD in their original (album) order?
    It seems to me that there is something very basic wrong with the way iTunes handles CD Tracks.
    Professionally produced CD tracks are seldom if ever in a randomised order. Why then does iTunes seem unable to display the tracks in the order they appear on the original CD source - whether from a personally owned CD or from a download from the iTunes Store?
    Some music demands a specific, non-alphabetic sequence in order to make sense. Why does it seem that iTunes only offers Alphabetic, or reverse alphabetic order - both of which make a nonsense of the original, often intended order of tracks?
    Why not replace the so-called "cover-art" in the bottom left hand corner if the iTunes window - which, while it may look attractive to some, gives the barest of information concerning the original disc, with a list of the original CD tracks in their original order, so that the user can easily reestablish the order in which they should be played.
    As I would expect legibility might be a problem with doing this, why could not the original contents, (in their original order), at least, be displayed when the "cover art" is double clicked-on - the result of which at present gives me an enlarged version of the "Cover Art". While on the subject of the contents of the source disc, what about all the album notes which someone takes trouble to write in order to increase the appreciation of the music on the CD and the listener's general background knowledge of the artists involved. Such notes, it seems to me, have considerable intrinsic value in their own account. I would, I think, normally be prepared to buy such "Sleeve notes" - so long as a "taster" was supplied (as it is for the music) - for something like the cost of a single 'Tune" on iTunes.
    These two aspects let Apple iTunes down enormously, in my opinion. I think that by chopping even quite protracted sequences of music up into bits does no one any favours - except perhaps Apple's already quite substantial bank balance. People have to be aware that two and a half, to three and a half minutes is a very short time to develop a piece of worthwhile music, and that there are many, many composers, not all of whom are alive today who have written music that huge masses of mankind value for the enrichment of their lives and the human condition in general.
    Please make the viewing of iTunes tracks in their correct order by default possible. By all means have the alphabetical variations available as offering a different approach to the music, but not the sole approach to it - PLEASE.
    Frustratedly yours
    Alan Whitaker
    PS I work at my old 24" iMac Intel Core 2 machine which runs OS "Tiger" - because it is more beautiful to look at, the screen is more pleasant to work on, and because, in some ways it is more capable (it will run FreeHand MX without needing a "patch"), than my more recent 21.5" which runs "Snow Leopard". (I don't find it that much slower, either).

    Dear Mike
    Thanks for the support. I am utterly amazed that after all the hype about how good iTunes is that it cannot play a downloaded CD in the correct order, and that what that order should be is not available directly from within one's own iTunes installation. (I know that one can go back to the iTunes Store to check what the order should be, but having downloaded the tracks surely iTunes is clever enough to retrieve this important information.
    My iTunes to differ from yours in that I have also noticed that it seems unable to download copies of my "talking books" in the correct order either. But in my case it downloads them - from a CD - in order, but with the first track downloaded first - so that it appears at the bottom of the column of tracks so that it would get played last! (At least this is, while being inexplicable, a relatively "logical" bit of blundering and because of this is relatively easy to put right!).
    I like many genres of music, some of which are not really programmed except perhaps by the artist performing them. I know that Frank Sinatra was very careful to programme his album songs to obtain a particular effect and in relation to the keys of the music. iTunes presumes to know better.
    Film scores may be totally randomly put together, in some cases, but in others the order is vital to one's appreciation of the music as a whole and how it relates to the plot of the film.
    In symphonic music most works are divided into sections and are conceived by the composer that way. Some individual sections may gain a life of their own if played separately, but they are never complete in the sense that the composer envisaged them without being placed in their proper context.
    Opera and probably most choral music too, is similar except that the words may well become meaningless if the order is changed at the whim of a piece of ill-written computer code, while ballet music has to be heard totally within its sequential context or it becomes meaningless.
    Finally, I would venture that iTunes, by jumbling up the order of the tracks as recorded on a CD, does an immense disservice, not only to the music on a particular CD, but to music in general, by expressing everything in terms of "Songs" - which it seems to interpret as stand-alone items of between 2 and 4 minutes whatever the genre. Even the way the iTunes publicity speaks of how many "songs" it can store instead of how many minutes or hours of recorded sound. This has to be another brick in the wall of "dumming-down" of people's expectations, and the shortening of their attention spans.
    I don't know about anyone else, but I feel betrayed by Apple over this. Perhaps the look, feel and general presentation of an item are not the most desirable features of a consumer product. Maybe it should be judged more on it fitness for the purpose for which it was sold. There is one other possibility - that Apple are trying to redefine "Music" - and that everything that lasts longer than about 3.5 minutes or is in the form of what could for want of a better term be called symphonic in the broadest sense is something else - not "Music" within Apple's new definition, at all!
    Well that's off my chest! now I can get down to creating some sort of order in my iTunes Libraries, knowing that I have to reconsult all the sources in order to confirm the source playing order.
    Anyway thanks again. At least I know that it is not just me
    alanfromthatcham

  • How can I use Office Update without the Office CD?

    How can I use Office Update without the Office CD? On the microsoft website I've clicked the options which mean I shouldn't need the CD (which wasn't supplied with the laptop), but poartway through updating the service pack I get a request for the Office 2000 Professional CD.
    Any suggestions?

    Hi
    Did you mean a Office or One Note?
    As far as I know the One Note is a part of the Recovering Image and the CD is not delivered with the unit. Furthermore the Toshiba units are not delivered with the Office 2000 software.
    Nevertheless, did you check the update function in the Help i.e. in Word?
    There you will find a options called Check for Updates
    http://office.microsoft.com/en-us/officeupdate/default.aspx
    Bye

  • In disk utility, it shows that my external hard drive is somehow unmounted and I can't access it in finder or repair it in Disk Utility. How can I get this working without losing my important data?

    In disk utility, it shows that my external hard drive is somehow unmounted and I can't access it in finder or repair it in Disk Utility. How can I get this working without losing my important data?
    Thank you!

    When you erased the disk did you select Mac OS Extended Journaled as the format option?

  • My charger is stuck in USB port of my car , how can I get it out without damaging either ?

    The charger that came with my iPhone 5c is now stuck in the USB port of my car. How can I get it out without damaging either?

    Use this article: If you can't update or restore your iOS device - Apple Support
    Best of luck!  And since you didn't back up your data previously, all your data is lost.  Make sure to use the free backup services of iCloud or iTunes.
    iOS: How to back up and restore your content - Support - Apple - http://support.apple.com/kb/HT1766

  • My marketplace has lost his CSS-Layout! How can I get it back/install the marketplace new?

    Hi,
    since a few weeks, when I start the Firefox Os marketplace, I see an unformatted HTML-page without any layout. Somehow I lost the layout information. How can I get it back? The first idea was reinstalling the marketplace. But it is not an app in the marketplace...
    Please help me. using the marketplace without layout is not usable for a longer time.
    Alle other apps are working fine. The marketplace had an layout, when i bought the smartphone (ZTE Open C).
    regards
    AK

    Hi Ralph,
    thank you for your quick response.
    I saw a simple HTML-Page in white, all links in blue or purple. I expected the normal marketplace-layout.
    After opening your link at the browser and adding a favorit to the desktop my original marketplace-App-Button works fine again. Now even using the App-Button the layout is back again. Sometimes it can be so simple...
    So you solved the problem for me.
    Thanks a lot
    tryme

  • I had 21 songs i my album and after syncronising i only had 15 songs left! All of them from Itunes! How can i get them back without paying for them again???

    I had 21 songs i my album and after syncronising i only had 15 songs left! All of them from Itunes! How can i get them back without paying for them again???
    Hello!!!
    I had 21 songs i my album and after syncronising i only had 15 songs left! All of them from Itunes! How can i get them back without paying for them again???
    Hello!!!
    This realy works??

    Where is the backup of the media and other important files from the computer?  Ultimately, it is the users responsibility to ensure that backups exists. Waiting until there is a problem to decide to do a backup is not smart.  Would you wait until a fire started in your home to call the insurance company and inquire about homeowners/renters insurance????
    In the event that no backup exists (stop being lazy.... keep backups of YOUR data and other important files):
    If you are in the US and running iTunes 10.3 or later, it is possible to redownload music via iCloud from purchased history.
    If you are not in the US or for some reason cannot run iTunes 10.3 or later, contact iTunes customer support and ask very nicely for the opportunity to redownload the content.  They are not required to provide this opportunity.
    It is also possible to transfer content from an iDevice that was purchased via iTunes.  On the new computer, sign into the iTunes account, authorize the computer, connect the device then select File > Transfer Purchases.
    The simplest method of all is to transfer or copy the media (and other important files) from the old computer or the backup of the old computer.  Typing "move itunes library" into the search bar here or into google will reveal step by step instructions on how to do this.

  • HT4993 I have a disabled iphone i forgot my passcode, how can i get it unlocked without loosing my data?

    I have a disabled iphone i forgot my passcode, how can i get it unlocked without loosing my data?

    As the manual says, you will have to restore your iphone.

  • How can i use my account without the billing info, as i do not have a credit card. and my shipping and billing info is under US. i'm in singapore. how do i change this?

    how can i use my account without the billing info, as i do not have a credit card. and my shipping and billing info is under US. i'm in singapore. how do i change this?

    If you are just visiting Singapore, then leave the account as it is. If you have moved there, then view your account using the iTunes app on a Mac or PC and change the country/region to your current location and address. If you do not have a bank card, you can fund your account using iTunes gift cards if available in Singapore.

Maybe you are looking for