content: package com.aliyun.dts.demo.utils;
  
  import com.alicloud.openservices.tablestore.SyncClient;
  import com.alicloud.openservices.tablestore.core.utils.IOUtils;
  import com.fasterxml.jackson.databind.JsonNode;
  import com.fasterxml.jackson.databind.ObjectMapper;
  
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.io.InputStream;
  
  /**
   * @author hydrogen
   */
  public class Utils {
  
      public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
  
      public static JsonNode getClientAndConfig() {
          final String pathSeparator;
          String os = System.getProperty("os.name");
          if (os.toLowerCase().startsWith("win")) {
              pathSeparator = "\\";
          } else {
              pathSeparator = "/";
          }
  
          final InputStream inputStream;
          try {
              inputStream = new FileInputStream(System.getProperty("user.home") + pathSeparator + "tablestoreConf.json");
          } catch (FileNotFoundException e) {
              throw new RuntimeException(e);
          }
          // parse config in config file
          JsonNode config;
          try {
              config = OBJECT_MAPPER.readTree(inputStream);
          } catch (IOException e) {
              throw new RuntimeException(e);
          } finally {
              IOUtils.safeClose(inputStream);
          }
          return config;
      }
  
  }
  