I've got two String-related questions.
String parameter, but no information is given as to which String parameters are acceptable. As an example, the InputStreamClass has a constructor that takes the parameters (InputStream in, String enc). How is one to know the acceptable values for the encoding parameter?String enc in the constructor below?String(byte[]b,String enc);
Let's look at the APIs in question:
String(byte[] bytes) String(byte[] bytes, int offset, int length) String(byte[] bytes, int offset, int length, String enc) String(byte[] bytes, String enc)
Each of these String constructors takes a byte array as an argument. The array contains string data encoded as raw bytes. The encoding argument
tells the constructor what format the byte data takes. The constructor then uses the encoding information to convert the raw
bytes into a readable string. The constructor that doesn't have an encoding argument simply uses the default encoding for
your system.
So, what constitutes acceptable parameters? Well, the parameter you pass in will obviously depend on how the string is encoded.
You'll also be limited to the String encodings supported by Java.
Instead of copying all of the supported types here, I'll just point you to a Webpage where you can get the list. The encoding.doc.html page lists each and every encoding supported by Java.