Mercurial > 510Connectbot
comparison app/src/main/java/ch/ethz/ssh2/util/StringEncoder.java @ 438:d29cce60f393
migrate from Eclipse to Android Studio
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 03 Dec 2015 11:23:55 -0800 |
parents | src/ch/ethz/ssh2/util/StringEncoder.java@071eccdff8ea |
children |
comparison
equal
deleted
inserted
replaced
437:208b31032318 | 438:d29cce60f393 |
---|---|
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 public static byte[] GetBytes(String data) { | |
16 try { | |
17 return data.getBytes("UTF-8"); | |
18 } | |
19 catch (UnsupportedEncodingException e) { | |
20 throw new RuntimeException(e); | |
21 } | |
22 } | |
23 | |
24 public static String GetString(byte[] data) { | |
25 return GetString(data, 0, data.length); | |
26 } | |
27 | |
28 public static String GetString(byte[] data, int off, int len) { | |
29 try { | |
30 return new String(data, off, len, "UTF-8"); | |
31 } | |
32 catch (UnsupportedEncodingException e) { | |
33 throw new RuntimeException(e); | |
34 } | |
35 } | |
36 } |