Should I be importing com.apple.eawt (I seem to have downloaded a
copy of this in AppleJavaExtensions.jar - apparently version 1.2) and
using the FileManager methods such as
setFileType(java.lang.String filename, int type) ? And if so, don't
laugh, how do I represent a file type like TEXT as an integer?
Yes, com.apple.eawt.FileManager is the replacement in 1.4
for the routines you have been using. If you want the code
to continue to work in 1.3 Mac JVMs you'll need to try both
using reflection. If you only care about 1.4+, just convert
over to FileManager.
As for the constants, in some cases you can use Apple-defined
constants, but in many cases you can't. The int values are
what you would get in C with code like:
const int TEXT_TYPE = 'TEXT';
This assigns a 4-byte constant whose bytes have the values
of the ASCII code for T, E, X and T, respectively. I
believe, but have not yet confirmed, that the byte order does
not change on little endian CPUs. For example, the same
C declaration used above could also be written:
const int TEXT_TYPE = 0x54455854;
and the compiler would generate a constant in the object
file that (on a little endian system) would use the reversed
byte order, so it produced 0x54455854 when loaded. You can
see the set of ASCII character codes in hex by entering the
Terminal command "man ascii".
In any case, for Java use you should prefer defining these
using hex literals. If you really have to convert a String,
get the byte array using the "MacRoman" encoding, and then
shift the bytes into the int. There was a discussion on this
list about the pitfalls of doing so some time ago.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden