We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › MimeType of file
Page Index Toggle Pages: 1
MimeType of file (Read 303 times)
MimeType of file
Jun 2nd, 2008, 10:41pm
 
Hello everyone -

i wonder how to get the mimetype of an file.
via

File[] files = new File("/Users/me/Documents/Processing/processing/applicationx/data/").listFiles()
;
 
 for( int i=0; i < files.length; i++ ) {
   println("Mime Type of " + files[i].getName() + " is " + files[i].getMimeType() );
 }

processing gets the files in the folder. but the 'getMimeType'-java keyword won't be accepted. i found no sample so far. can someone help ?

also i found no way to use relative paths, i always have to set the full system-path. how can i tell processing the data-folder is in the application-folder via code without to save the complete system-path ... ?

thank everyone for response -
tobi.
Re: MimeType of file
Reply #1 - Jun 3rd, 2008, 12:46am
 
First link found after a quick Google search: Get the Mime Type from a File
Looks like there are several solutions.

From what I remember, the application folder is the current directory: if you save a file without giving a path, it is saved in the application folder.
I tried to save with a path of "data/foo.ext", and it went in the data directory of the application. On Windows XP.
FYI: Java Applications and the "Current Directory"
Re: MimeType of file
Reply #2 - Jun 3rd, 2008, 10:42am
 
Hi PhiLho -

thanks for reply. Yes, Google finds some solutions. But it's always for native Java-Applications and sometimes hard for me to understand because Processing is also new for me.
But this time it works. Thank you for the link.

The problem with the directory i can't fix at the time. Because having subfolders in the data-path i have to give a pathname and that's why Processing seems to need the full-path beginning by the root of the system ...

tobi.
Page Index Toggle Pages: 1