Bug 530015 - Use StandardCharsets in console bundles

Change-Id: I2c1e775f33e7b25897a641b2d426b39cfcd26471
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeys.java b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeys.java
index be0f1a8..09cd006 100644
--- a/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeys.java
+++ b/bundles/org.eclipse.equinox.console.ssh/src/org/eclipse/equinox/console/internal/ssh/AuthorizedKeys.java
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2011, 2017 Gunnar Wagenknecht and others.
+ * Copyright (c) 2011, 2018 Gunnar Wagenknecht and others.
  * All rights reserved.
  *
  * This program and the accompanying materials are made available under the terms of the
@@ -14,9 +14,9 @@
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.math.BigInteger;
 import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
 import java.security.KeyFactory;
 import java.security.NoSuchAlgorithmException;
 import java.security.PublicKey;
@@ -62,19 +62,11 @@
 	private static final String NEWLINE = "\n";
 
 	private static byte[] asBytes(final String string) {
-		try {
-			return string.getBytes("UTF-8");
-		} catch (final UnsupportedEncodingException e) {
-			return string.getBytes();
-		}
+			return string.getBytes(StandardCharsets.UTF_8);
 	}
 
 	private static String asString(final byte[] bytes) {
-		try {
-			return new String(bytes, "UTF-8");
-		} catch (final UnsupportedEncodingException e) {
-			return new String(bytes);
-		}
+			return new String(bytes, StandardCharsets.UTF_8);
 	}
 
 	public static void main(final String[] args) {
diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/HistoryHolder.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/HistoryHolder.java
index 1e304b5..820262e 100755
--- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/HistoryHolder.java
+++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/common/HistoryHolder.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2011 SAP AG
+ * Copyright (c) 2010, 2018 SAP AG
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -11,7 +11,7 @@
 
 package org.eclipse.equinox.console.common;
 
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 
 /**
@@ -37,11 +37,7 @@
     }
 
     public synchronized void add(byte[] data) {
-        try {
-            data = new String(data, "US-ASCII").trim().getBytes("US-ASCII");
-        } catch (UnsupportedEncodingException e) {
-
-        }
+        data = new String(data, StandardCharsets.US_ASCII).trim().getBytes(StandardCharsets.US_ASCII);
         if (data.length == 0) {
             pos = size;
             return;