3

Is there an equivalent of C's MAX_PATH constant in Java? Been troving the web for an answer and can't find one. Thanks

oldSkool
  • 1,212
  • 5
  • 14
  • 29
  • 1
    MAX_PATH has nothing to do with the C language. It's platform-defined by Windows and POSIX (the latter as PATH_MAX iirc). Are you thinking of `FILENAME_MAX`? – David Titarenco Oct 29 '11 at 06:59
  • Anything that will give me the maximum number of allowed characters for the system that the applet is running on; which class of the Java platform it is located in – oldSkool Oct 29 '11 at 07:01

1 Answers1

3

No, there's no equivalent (especially for an applet). Unless you want to do JNI, you can't get that information. The only limit you may reach is the String max length limit (which is far beyond what any operating system would allow, anyway).

I assume either an exception would be thrown or the filename (or path) will be truncated. Here's a related question: Does Java IO have a maximum file name length?

Community
  • 1
  • 1
David Titarenco
  • 32,662
  • 13
  • 66
  • 111
  • 1
    alright; just writing some preventative measures into my programs to prevent longer filenames than the OS will allow. I'm more akin to testing values than catching exceptions (the old school way). Exceptions just look sloppy to me. *shrugs* – oldSkool Oct 29 '11 at 07:09