risdenk commented on a change in pull request #241: KNOX-1742 - Simple SQL Client in KnoxShell for access to JDBC sources URL: https://github.com/apache/knox/pull/241#discussion_r368778454
########## File path: gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxSession.java ########## @@ -593,21 +594,42 @@ public String toString() { String s = JsonUtils.renderAsJsonString(map); String home = System.getProperty("user.home"); try { - write(new File(home + File.separator + ".knoxshell" + File.separator + fileName), s); + write(new File( + home + File.separator + ".knoxshell" + File.separator + fileName), + s, StandardCharsets.UTF_8); } catch (IOException e) { e.printStackTrace(); } } - private static void write(File file, String s) throws IOException { + /** + * Persist provided Map to a file within the {user.home}/.knoxshell directory + * @param <T> + * @param fileName of persisted file + * @param map to persist + */ + public static <T> void persistDataSourcesToKnoxShell(String fileName, Map<String, T> map) { + String s = JsonUtils.renderAsJsonString(map); + String home = System.getProperty("user.home"); + try { + write(new File( + home + File.separator + + ".knoxshell" + File.separator + fileName), + s, StandardCharsets.UTF_8); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void write(File file, String s, Charset utf8) throws IOException { Review comment: Don't need to expose `Charset`. UTF8 is correct in every case so far. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services