comparison src/ch/ethz/ssh2/util/StringEncoder.java @ 308:42b15aaa7ac7 ganymed

merge
author Carl Byington <carl@five-ten-sg.com>
date Wed, 30 Jul 2014 14:21:50 -0700
parents 071eccdff8ea
children
comparison
equal deleted inserted replaced
306:90e47d99ea54 308:42b15aaa7ac7
9 9
10 /** 10 /**
11 * @author Christian Plattner 11 * @author Christian Plattner
12 * @version $Id: StringEncoder.java 43 2011-06-21 18:34:06Z dkocher@sudo.ch $ 12 * @version $Id: StringEncoder.java 43 2011-06-21 18:34:06Z dkocher@sudo.ch $
13 */ 13 */
14 public class StringEncoder 14 public class StringEncoder {
15 { 15 public static byte[] GetBytes(String data) {
16 public static byte[] GetBytes(String data)
17 {
18 try { 16 try {
19 return data.getBytes("UTF-8"); 17 return data.getBytes("UTF-8");
20 } 18 }
21 catch(UnsupportedEncodingException e) { 19 catch (UnsupportedEncodingException e) {
22 throw new RuntimeException(e); 20 throw new RuntimeException(e);
23 } 21 }
24 } 22 }
25 23
26 public static String GetString(byte[] data) 24 public static String GetString(byte[] data) {
27 { 25 return GetString(data, 0, data.length);
28 return GetString(data, 0, data.length); 26 }
29 }
30 27
31 public static String GetString(byte[] data, int off, int len) 28 public static String GetString(byte[] data, int off, int len) {
32 {
33 try { 29 try {
34 return new String(data, off, len, "UTF-8"); 30 return new String(data, off, len, "UTF-8");
35 } 31 }
36 catch(UnsupportedEncodingException e) { 32 catch (UnsupportedEncodingException e) {
37 throw new RuntimeException(e); 33 throw new RuntimeException(e);
38 } 34 }
39 } 35 }
40 } 36 }