Hello Kartik1801,
I assume you are using java.io.FileDialog in your existing application
"so the user can select the desired files...". If this is not correct
- use a clarification request that describes your method of file
selection so I can provide a more complete answer.
Perhaps the easiest way to do what you want is to use one (or both)
packages from Informagen
http://www.informagen.com/java/FilenameFilter/index.html
there are two packages here
FilterByMacOSType - filters files by type / creator [Classic Mac]
FilterBySuffix - filters file by extension [Mac OS X]
I tag these as "classic" and "OS X", but after reviewing the code - I
don't see anything specific that would prevent you from using either
on both OS versions. These work to implement java.io.FilenameFilter
used by java.io.FileDialog.
There are also code fragments that describe how to set up / call these
packages. The specific example is for images (GIF, JPEG), but can be
adapted for other file types as well. If you don't know the Mac file
types you need - let me know - I can hunt those down for you as well.
A few other references that may help
[1] Your First Cup of Java (for Mac OS)
http://java.sun.com/docs/books/tutorial/getStarted/cupojava/mac.html
which describes a simple application, getting the tools for the Mac,
etc.
[2] Class JFileChooser (if using Swing)
http://java.sun.com/j2se/1.3/docs/api/javax/swing/JFileChooser.html
I was pointed here by another page indicating that the FileDialog
package did not implement file filters on Windows. The packages above
may work with the file filter here as well - I can't be sure.
[3] Building the Image File Filter
http://developer.apple.com/java/javatutorial/imagenamefilter.html
An apple site showing the use of file extensions (instead of file
types) to filter files. Part of a larger java tutorial.
[4] A Bundle of Java
http://www.mactech.com/articles/mactech/Vol.15/15.08/ABundleofJava/
A complete application developed for the Mac in java. Includes a
description of how the data fork and resource fork are used, the
creator code (application id), and file types. Includes some low level
calls to set up files w/ the appropriate settings for both.
Search phrases for more information include
macintosh java file dialog
macintosh java file dialog "creator code"
macintosh java file dialog "file type"
This should get you on the road to satisfying your Mac users. Don't
hesitate to request clarification if some part of this is unclear or
you need further information.
--Maniac |
Clarification of Answer by
maniac-ga
on
08 Oct 2003 15:28 PDT
Hello Kartik1801,
Well, first - you don't have any "drive letters" on the Macintosh. For
Mac OS X systems, your file names can be handled just like any other
Unix system. For example
/ refers to the root of the file system
There are a few conventions that are a little different than most Unix
systems. For example:
/Volumes/My Disk
will refer to a drive named "My Disk" (note the name can be long, have
spaces, etc.). The user directories are normally in
/Users/
and the folders / files in the top level directory will be often be in
mixed case (usually Unix top level directories are always in lower
case).
As far as I can tell - all the operations you are familiar with
listFiles()
listFiles(FileFilter filter)
listFiles(FilenameFilter filter)
FileSystemView.isDrive(File dir)
and so on are available. For example, the apple developer site lists:
http://developer.apple.com/documentation/Java/Conceptual/Java141Development/Core_APIs/index.html
which states that the java core API's work pretty much unchanged and I
can't find any information to say otherwise.
As a side comment
http://www.chinalinuxpub.com/doc/oreillybookself/java/exp/ch08_02.htm
has some good suggestions related to making applications portable
between the Mac and Windows - for example, use File.separator or
File.separatorChar to get the slash (forward or backward) to separate
the directory / file name. As another example, use the isDirectory()
to ensure you are dealing with a directory.
The only drawback I can see from what you describe is that it does not
necessarily "look right" when compared with other Mac applications.
You describe a windows explorer like interface - that might look odd
to a Mac user that expects to see the standard file dialog interface.
--Maniac
|