001    package com.nimbusds.jose.util;
002    
003    
004    import java.nio.charset.Charset;
005    
006    import com.nimbusds.jose.JOSEException;
007    
008    
009    /**
010     * String utilities.
011     *
012     * @author Vladimir Dzhuvinov
013     * @version $version$ (2013-05-16)
014     */
015    public class StringUtils {
016    
017    
018            /**
019             * Converts the specified string to a byte array.
020             *
021             * @param s The input string to convert. Must be UTF-8 encoded and not
022             *          {@code null}.
023             *
024             * @return The resulting byte array.
025             */
026            public static byte[] toByteArray(final String s) {
027    
028                    return s.getBytes(Charset.forName("UTF-8"));
029            }
030    
031    
032            /**
033             * Prevents public instantiation.
034             */
035            private StringUtils() {
036    
037            }
038    }