• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spliting a file name

 
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am writing a program that that reads a file of .gif images and stores them. It has worked well, until lately, a file called Thumbs.db gets read in, even through Windows explorer can not find it, even with searching hidden files as well. Does anyone know what this file is and how to delete it completely, and keep it from rearing its ugly head?

This got me thinking, people can add in their own images, but they must be transparent .gif files or it will look weird. So I tried to split the file name between the . and compare the extension.

String[] spl = str.split("\\.") returns the entire string. Just using "." because it is a predefined regex expression, so how do I split a string like this?
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, str.split("\\.") should do it. If it's not working for you, it's possible that either the input does not actually have a . in it, or that you're not reading the contents of spl correctly. Here's a short demo:
 
David McCombs
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought it should work but am mystified why it doesn't.

The file names all have a . in them ie fish1.gif. fish2.gif, Thumbs.db,etc

I will go through it again, must be something that is subtle.

Thank you for confirming that I had the split argument correct.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thumbs.db? That's just a file that Windows puts in a directory with lots of pictures if you open Windows Explorer and display the directory in "thumbnail" mode. I don't know what it's for but it's obviously something to do with the images. To delete it, just click on it and press the delete key just like any other file.
 
David McCombs
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would but it doesn't show up in Windows Explorer, even though it is set to list all files, even hidden ones. I got the split problem worked out so my program doesn't try to read it as an Image.
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thumbs.db is not viewable even when the "Show hidden files and folders" option is selected in the "Folder Options" dialogue box. To be able to view it, you have to unselect the "Hide protected opertaing system files (Recommended)" that is selected by default.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic