comparison src/ch/ethz/ssh2/util/StringEncoder.java @ 273:91a31873c42a ganymed

start conversion from trilead to ganymed
author Carl Byington <carl@five-ten-sg.com>
date Fri, 18 Jul 2014 11:21:46 -0700
parents
children 071eccdff8ea
comparison
equal deleted inserted replaced
272:ce2f4e397703 273:91a31873c42a
1 /*
2 * Copyright (c) 2006-2011 Christian Plattner.
3 * All rights reserved.
4 * Please refer to the LICENSE.txt for licensing details.
5 */
6 package ch.ethz.ssh2.util;
7
8 import java.io.UnsupportedEncodingException;
9
10 /**
11 * @author Christian Plattner
12 * @version $Id: StringEncoder.java 43 2011-06-21 18:34:06Z dkocher@sudo.ch $
13 */
14 public class StringEncoder
15 {
16 public static byte[] GetBytes(String data)
17 {
18 try {
19 return data.getBytes("UTF-8");
20 }
21 catch(UnsupportedEncodingException e) {
22 throw new RuntimeException(e);
23 }
24 }
25
26 public static String GetString(byte[] data)
27 {
28 return GetString(data, 0, data.length);
29 }
30
31 public static String GetString(byte[] data, int off, int len)
32 {
33 try {
34 return new String(data, off, len, "UTF-8");
35 }
36 catch(UnsupportedEncodingException e) {
37 throw new RuntimeException(e);
38 }
39 }
40 }