/** * Set the contents of the file represented by this entry, using the specified charset. * * @param contents - the String whose bytes are used as the contents * @param charset - the charset used to convert the string to a byte[] * * @throws UnsupportedEncodingException - if an error occurs converting the String to a byte[] using the specified charset */ public void setContents(String contents, String charset) throws UnsupportedEncodingException { byte[] newBytes = (contents != null) ? contents.getBytes(charset) : EMPTY; setContentsInternal(newBytes); }
/** * Set the contents of the file represented by this entry * * @param contents - the String whose bytes are used as the contents */ public void setContents(String contents) { byte[] newBytes = (contents != null) ? contents.getBytes() : EMPTY; setContentsInternal(newBytes); }
/** * Set the contents of the file represented by this entry * * @param contents - the byte[] used as the contents */ public void setContents(byte[] contents) { // Copy the bytes[] to guard against subsequent modification of the source array byte[] newBytes = EMPTY; if (contents != null) { newBytes = new byte[contents.length]; System.arraycopy(contents, 0, newBytes, 0, contents.length); } setContentsInternal(newBytes); }