Ejemplo n.º 1
1
 private String getCIJobPath(ApplicationInfo appInfo) {
   StringBuilder builder = new StringBuilder(Utility.getProjectHome());
   builder.append(appInfo.getAppDirName());
   builder.append(File.separator);
   builder.append(FOLDER_DOT_PHRESCO);
   builder.append(File.separator);
   builder.append(CI_JOB_INFO_NAME);
   return builder.toString();
 }
Ejemplo n.º 2
0
  private void setSvnCredential(CIJob job) throws JDOMException, IOException {
    S_LOGGER.debug("Entering Method CIManagerImpl.setSvnCredential");
    try {
      String jenkinsTemplateDir = Utility.getJenkinsTemplateDir();
      String credentialFilePath = jenkinsTemplateDir + job.getRepoType() + HYPHEN + CREDENTIAL_XML;
      if (debugEnabled) {
        S_LOGGER.debug("credentialFilePath ... " + credentialFilePath);
      }
      File credentialFile = new File(credentialFilePath);

      SvnProcessor processor = new SvnProcessor(credentialFile);

      //			DataInputStream in = new DataInputStream(new FileInputStream(credentialFile));
      //			while (in.available() != 0) {
      //				System.out.println(in.readLine());
      //			}
      //			in.close();

      processor.changeNodeValue("credentials/entry//userName", job.getUserName());
      processor.changeNodeValue("credentials/entry//password", job.getPassword());
      processor.writeStream(new File(Utility.getJenkinsHome() + File.separator + job.getName()));

      // jenkins home location
      String jenkinsJobHome = System.getenv(JENKINS_HOME);
      StringBuilder builder = new StringBuilder(jenkinsJobHome);
      builder.append(File.separator);

      processor.writeStream(new File(builder.toString() + CI_CREDENTIAL_XML));
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into the catch block of CIManagerImpl.setSvnCredential "
              + e.getLocalizedMessage());
    }
  }
  private BusinessPartnerCategoryData getEditVariables(Connection con, VariablesSecureApp vars)
      throws IOException, ServletException {
    BusinessPartnerCategoryData data = new BusinessPartnerCategoryData();
    ServletException ex = null;
    try {
      data.adOrgId = vars.getRequiredGlobalVariable("inpadOrgId", windowId + "|AD_Org_ID");
      data.adOrgIdr = vars.getStringParameter("inpadOrgId_R");
      data.cBpGroupId = vars.getRequestGlobalVariable("inpcBpGroupId", windowId + "|C_BP_Group_ID");
      data.value = vars.getStringParameter("inpvalue");
      data.name = vars.getRequiredStringParameter("inpname");
      data.description = vars.getStringParameter("inpdescription");
      data.isactive = vars.getStringParameter("inpisactive", "N");
      data.isdefault = vars.getStringParameter("inpisdefault", "N");
      data.adClientId = vars.getRequiredGlobalVariable("inpadClientId", windowId + "|AD_Client_ID");
      data.createdby = vars.getUser();
      data.updatedby = vars.getUser();
      data.adUserClient = Utility.getContext(this, vars, "#User_Client", windowId, accesslevel);
      data.adOrgClient =
          Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel);
      data.updatedTimeStamp = vars.getStringParameter("updatedTimestamp");

      if (data.value.equals(""))
        data.value =
            Utility.getDocumentNoConnection(con, this, vars.getClient(), "C_BP_Group", true);
    } catch (ServletException e) {
      vars.setEditionData(tabId, data);
      throw e;
    }
    // Behavior with exception for numeric fields is to catch last one if we have multiple ones
    if (ex != null) {
      vars.setEditionData(tabId, data);
      throw ex;
    }
    return data;
  }
Ejemplo n.º 4
0
  public boolean tryDamageSkill(String rem, String cut, String output) {

    if (cut.length() > 0)
      if (rem.indexOf(cut) == 0) {
        rem = rem.substring(cut.length(), rem.length());
        rem = Utility.clearWhiteSpace(rem);
      }

    target = owner.getRoom().findEntity(owner, rem);

    if ((target == null) && (owner.getPlayerState() == Utility.PSTATE_FIGHTING))
      target = owner.getTarget();

    if (target == null) {
      owner.echo(output);
      return false;
    }

    if (!Combat.canAttack(owner, target, false, true)) return false;

    tn = target.getName();
    Tn = target.getPName();
    ty = Utility.possessive(tn);
    Ty = Utility.possessive(Tn);

    return true;
  }
Ejemplo n.º 5
0
 public void printVariable() {
   Utility.Dprintc("VARIABLE " + varID + " ", 0);
   for (int j = 0; j < domain.length; j++) {
     Utility.Dprintc(domain[j].toString() + " ", 0);
   }
   Utility.Dprint("", 0);
 }
Ejemplo n.º 6
0
    private static DialogFeatureConfig parseDialogConfig(JSONObject dialogConfigJSON) {
      String dialogNameWithFeature = dialogConfigJSON.optString(DIALOG_CONFIG_NAME_KEY);
      if (Utility.isNullOrEmpty(dialogNameWithFeature)) {
        return null;
      }

      String[] components =
          dialogNameWithFeature.split(DIALOG_CONFIG_DIALOG_NAME_FEATURE_NAME_SEPARATOR);
      if (components.length != 2) {
        // We expect the format to be dialogName|FeatureName, where both components are
        // non-empty.
        return null;
      }

      String dialogName = components[0];
      String featureName = components[1];
      if (isNullOrEmpty(dialogName) || isNullOrEmpty(featureName)) {
        return null;
      }

      String urlString = dialogConfigJSON.optString(DIALOG_CONFIG_URL_KEY);
      Uri fallbackUri = null;
      if (!Utility.isNullOrEmpty(urlString)) {
        fallbackUri = Uri.parse(urlString);
      }

      JSONArray versionsJSON = dialogConfigJSON.optJSONArray(DIALOG_CONFIG_VERSIONS_KEY);

      int[] featureVersionSpec = parseVersionSpec(versionsJSON);

      return new DialogFeatureConfig(dialogName, featureName, fallbackUri, featureVersionSpec);
    }
 private void refreshSessionNew(VariablesSecureApp vars) throws IOException, ServletException {
   BusinessPartnerCategoryData[] data =
       BusinessPartnerCategoryData.selectEdit(
           this,
           vars.getSessionValue("#AD_SqlDateTimeFormat"),
           vars.getLanguage(),
           vars.getStringParameter("inpcBpGroupId", ""),
           Utility.getContext(this, vars, "#User_Client", windowId),
           Utility.getContext(this, vars, "#AccessibleOrgTree", windowId, accesslevel));
   if (data == null || data.length == 0) return;
   refreshSessionEdit(vars, data);
 }
Ejemplo n.º 8
0
  /**
   * Utility method that converts a class reference in the constant pool, i.e., an index to a
   * string.
   */
  static String referenceClass(int index) {
    String str = constant_pool.getConstantString(index, CONSTANT_Class);
    str = Utility.compactClassName(str);
    str = Utility.compactClassName(str, class_package + ".", true);

    return "<A HREF=\""
        + class_name
        + "_cp.html#cp"
        + index
        + "\" TARGET=ConstantPool>"
        + str
        + "</A>";
  }
Ejemplo n.º 9
0
  public void init(Entity Owner, int Level) {

    owner = Owner;
    level = Level;

    if (Owner != null) {

      mn = owner.getName();
      Mn = owner.getPName();
      my = Utility.possessive(mn);
      My = Utility.possessive(Mn);
    }
  }
Ejemplo n.º 10
0
 private void writeDoCommand(PrintWriter pw, String indent) {
   String str = indent + "fCommandStatus = fUMart.do" + fCmdDef.getCmdName() + "(";
   str += Utility.makeFieldString((String) fCmdDef.getReturnData().get("NAME"));
   str += ", userID";
   Iterator itr = fCmdDef.getArgList().iterator();
   while (itr.hasNext()) {
     HashMap argInfo = (HashMap) itr.next();
     String argName = Utility.makeFieldString((String) argInfo.get("NAME"));
     str += ", " + argName;
   }
   str += ");";
   pw.println(str);
 }
Ejemplo n.º 11
0
 private void writeSendingHashMap(PrintWriter pw, String indent, HashMap item, String hashName) {
   String coreClassName = "UC" + fCmdDef.getCmdName() + "Core";
   String type = (String) item.get("TYPE");
   ArrayList contents = (ArrayList) item.get("CONTENTS");
   Iterator itr = contents.iterator();
   while (itr.hasNext()) {
     HashMap item2 = (HashMap) itr.next();
     String type2 = (String) item2.get("TYPE");
     String name2 = (String) item2.get("NAME");
     String key2 = Utility.makeKeyString(type2, name2);
     String comment2 = (String) item2.get("COMMENT");
     String localVariableName = Utility.makeLocalVariable(name2);
     if (type2.equals("HashMap")) {
       pw.print(
           indent
               + "HashMap "
               + localVariableName
               + " = (HashMap)"
               + hashName
               + ".get("
               + coreClassName
               + "."
               + key2
               + ");");
       pw.println(" // " + comment2);
       writeSendingHashMap(pw, indent, item2, localVariableName);
     } else if (type2.equals("ArrayList")) {
       pw.print(
           indent
               + "ArrayList "
               + localVariableName
               + " = (ArrayList)"
               + hashName
               + ".get("
               + coreClassName
               + "."
               + key2
               + ");");
       pw.println(" // " + comment2);
       writeSendingArrayList(pw, indent, item2, localVariableName);
     } else {
       String str = indent + "fAgent.sendMessage(" + hashName + ".get(";
       str += "UC" + fCmdDef.getCmdName() + "Core." + key2 + ").toString());";
       pw.print(str);
       pw.println(" // " + comment2);
     }
   }
 }
Ejemplo n.º 12
0
 @Override
 public void mouseClicked(MouseEvent me) {
   Element el = doc.getCharacterElement(viewToModel(me.getPoint()));
   if (el == null) return;
   AttributeSet as = el.getAttributes();
   if (as.isDefined("ip")) {
     String ip = (String) as.getAttribute("ip");
     ScriptException se = (ScriptException) as.getAttribute("exception");
     Node node = net.getAtIP(ip);
     if (node == null) {
       Utility.displayError("Error", "Computer does not exist");
       return;
     }
     String errorString =
         "--ERROR--\n"
             + "Error at line number "
             + se.getLineNumber()
             + " and column number "
             + se.getColumnNumber()
             + "\n"
             + se.getMessage();
     new ScriptDialog(
             parentFrame,
             str -> {
               if (str != null) {
                 node.setScript(str);
               }
             },
             node.getScript(),
             errorString)
         .setVisible(true);
   }
 }
Ejemplo n.º 13
0
  /**
   * Override this method to create you own classes on the fly. The name contains the special token
   * $$BCEL$$. Everything before that token is consddered to be a package name. You can encode you
   * own arguments into the subsequent string. You must regard however not to use any "illegal"
   * characters, i.e., characters that may not appear in a Java class name too<br>
   * The default implementation interprets the string as a encoded compressed Java class, unpacks
   * and decodes it with the Utility.decode() method, and parses the resulting byte array and
   * returns the resulting JavaClass object.
   *
   * @param class_name compressed byte code with "$$BCEL$$" in it
   */
  protected JavaClass createClass(String class_name) {
    int index = class_name.indexOf("$$BCEL$$");
    String real_name = class_name.substring(index + 8);

    JavaClass clazz = null;
    try {
      byte[] bytes = Utility.decode(real_name, true);
      ClassParser parser = new ClassParser(new ByteArrayInputStream(bytes), "foo");

      clazz = parser.parse();
    } catch (Throwable e) {
      e.printStackTrace();
      return null;
    }

    // Adapt the class name to the passed value
    ConstantPool cp = clazz.getConstantPool();

    ConstantClass cl =
        (ConstantClass) cp.getConstant(clazz.getClassNameIndex(), Constants.CONSTANT_Class);
    ConstantUtf8 name = (ConstantUtf8) cp.getConstant(cl.getNameIndex(), Constants.CONSTANT_Utf8);
    name.setBytes(class_name.replace('.', '/'));

    return clazz;
  }
Ejemplo n.º 14
0
 // 获得文件长度
 public long getFileSize() {
   int nFileLength = -1;
   try {
     URL url = new URL(siteInfoBean.getSSiteURL());
     HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
     httpConnection.setRequestProperty("User-Agent", "NetFox");
     int responseCode = httpConnection.getResponseCode();
     if (responseCode >= 400) {
       processErrorCode(responseCode);
       return -2; // -2 represent access is error
     }
     String sHeader;
     for (int i = 1; ; i++) {
       // DataInputStream in = new
       // DataInputStream(httpConnection.getInputStream ());
       // Utility.log(in.readLine());
       sHeader = httpConnection.getHeaderFieldKey(i);
       if (sHeader != null) {
         if (sHeader.equals("Content-Length")) {
           nFileLength = Integer.parseInt(httpConnection.getHeaderField(sHeader));
           break;
         }
       } else break;
     }
   } catch (IOException e) {
     e.printStackTrace();
   } catch (Exception e) {
     e.printStackTrace();
   }
   Utility.log(nFileLength);
   return nFileLength;
 }
Ejemplo n.º 15
0
  public static Skill createSkill(String sName, Entity ENT, int lev) {

    Ability A = null;
    Class C = null;

    sName = Utility.getProperClassName(sName);

    try {
      C = Class.forName(sName);
      A = (Ability) C.newInstance();
    } catch (Exception e) {
      return null;
    } catch (Throwable t) {
      return null;
    }

    try {
      Skill Sk = (Skill) A;
      Sk.init(ENT, lev);
      return Sk;
    } catch (Exception e) {
      return null;
    } catch (Throwable t) {
      return null;
    }
  }
Ejemplo n.º 16
0
  public static DialogFeatureConfig getDialogFeatureConfig(
      String applicationId, String actionName, String featureName) {
    if (Utility.isNullOrEmpty(actionName) || Utility.isNullOrEmpty(featureName)) {
      return null;
    }

    FetchedAppSettings settings = fetchedAppSettings.get(applicationId);
    if (settings != null) {
      Map<String, DialogFeatureConfig> featureMap =
          settings.getDialogConfigurations().get(actionName);
      if (featureMap != null) {
        return featureMap.get(featureName);
      }
    }
    return null;
  }
Ejemplo n.º 17
0
  /* Get value with given name */
  public Value getValue(String val) {

    for (int i = 0; i < domain.length; i++) if (domain[i].toString().equals(val)) return domain[i];

    Utility.Dprint("Variable.getValue(): Unknown Value: " + val, Utility.TRACE_FUNCTION_LEVEL);
    return null;
  }
Ejemplo n.º 18
0
 public static File createTmpFile() {
   try {
     return File.createTempFile("Utility_temp_file-" + String.valueOf(Utility.tic()), ".tmp");
   } catch (IOException ex) {
     mylogger.log(Level.SEVERE, "Error: Can not create temp file ", ex);
     return null;
   }
 }
 private String getDisplayLogicContext(VariablesSecureApp vars, boolean isNew)
     throws IOException, ServletException {
   log4j.debug("Output: Display logic context fields");
   String result =
       "var strShowAudit=\""
           + (isNew ? "N" : Utility.getContext(this, vars, "ShowAudit", windowId))
           + "\";\n";
   return result;
 }
Ejemplo n.º 20
0
  static final String referenceType(String type) {
    String short_type = Utility.compactClassName(type);
    short_type = Utility.compactClassName(short_type, class_package + ".", true);

    int index = type.indexOf('['); // Type is an array?
    if (index > -1) type = type.substring(0, index); // Tack of the `['  	

    // test for basic type
    if (type.equals("int")
        || type.equals("short")
        || type.equals("boolean")
        || type.equals("void")
        || type.equals("char")
        || type.equals("byte")
        || type.equals("long")
        || type.equals("double")
        || type.equals("float")) return "<FONT COLOR=\"#00FF00\">" + type + "</FONT>";
    else return "<A HREF=\"" + type + ".html\" TARGET=_top>" + short_type + "</A>";
  }
Ejemplo n.º 21
0
 int getStatus(Exception e) {
   if (e instanceof JavaScriptException) {
     JavaScriptException je = (JavaScriptException) e;
     Object value = ((ScriptableObject) je.getValue()).get("message", null);
     if (value != null) {
       String status = Utility.find(value.toString(), "^\\d\\d\\d\\b");
       if (status != null) return Integer.parseInt(status);
     }
   }
   return 500;
 }
Ejemplo n.º 22
0
 /* Returns a negative integer, zero, or a positive integer as v1
 is less than, equal to, or greater v2.
 NOTE: assume values are ints.
 */
 public static int compareIntValues(Value val1, Value val2) {
   try {
     int vval1 = new Integer(val1.toString()).intValue();
     int vval2 = new Integer(val2.toString()).intValue();
     if (vval1 > vval2) return 1;
     else if (vval2 > vval1) return -1;
     return 0;
   } catch (Exception e) {
     Utility.Dprint("  Error in Variable.compareValues(): Vals are not ints." + e, 0);
   }
   return 0;
 }
Ejemplo n.º 23
0
  /** @return String representation, i.e., a list of thrown exceptions. */
  public final String toString() {
    StringBuffer buf = new StringBuffer("");
    String str;

    for (int i = 0; i < number_of_exceptions; i++) {
      str = constant_pool.getConstantString(exception_index_table[i], Constants.CONSTANT_Class);
      buf.append(Utility.compactClassName(str, false));

      if (i < number_of_exceptions - 1) buf.append(", ");
    }

    return buf.toString();
  }
Ejemplo n.º 24
0
  public static void main(String[] args) {
    test_email te1 = new test_email(123, "HI test");

    System.out.println("Test Serializalbe.");
    System.out.println("The original email is: " + te1.title + "  " + te1.content);

    String file_n = "test_email1";
    try {
      Utility.write_to(te1, file_n);
    } catch (IOException e) {
      e.printStackTrace();
    }
    test_email te2 = new test_email();
    try {
      te2 = (test_email) Utility.read_from(file_n);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    System.out.println("The readout email is: " + te2.title + "  " + te2.content);
  }
Ejemplo n.º 25
0
 private void writeSendingArrayList(
     PrintWriter pw, String indent, HashMap item, String arrayName) {
   String type = (String) item.get("TYPE");
   HashMap contents = (HashMap) item.get("CONTENTS");
   String name = Utility.makeLocalVariable((String) item.get("NAME"));
   String type2 = (String) contents.get("TYPE");
   String name2 = Utility.makeLocalVariable((String) contents.get("NAME"));
   String comment2 = (String) contents.get("COMMENT");
   pw.println(indent + "Iterator itr = " + arrayName + ".iterator();");
   pw.println(indent + "while ( itr.hasNext() ) {");
   if (type2.equals("HashMap")) {
     pw.println(indent + "  HashMap " + name2 + " = " + "(HashMap)itr.next();");
     writeSendingHashMap(pw, indent, contents, name2);
   } else if (type2.equals("ArrayList")) {
     pw.print(indent + "  ArrayList " + name2 + " = (ArrayList)itr.next();");
     writeSendingArrayList(pw, indent, contents, name2);
   } else {
     pw.print(indent + "  fAgent.sendMassage(" + name2 + ".toString());");
     pw.println(" // " + comment2);
   }
   pw.println(indent + "}");
 }
Ejemplo n.º 26
0
  /** @return string representation. */
  public final String toString() {
    String name = getName(), signature = Utility.signatureToString(getSignature());

    return "LocalVariable(start_pc = "
        + start_pc
        + ", length = "
        + length
        + ", index = "
        + index
        + ":"
        + signature
        + " "
        + name
        + ")";
  }
Ejemplo n.º 27
0
  private void setMailCredential(CIJob job) {
    if (debugEnabled) {
      S_LOGGER.debug("Entering Method CIManagerImpl.setMailCredential");
    }
    try {
      String jenkinsTemplateDir = Utility.getJenkinsTemplateDir();
      String mailFilePath = jenkinsTemplateDir + MAIL + HYPHEN + CREDENTIAL_XML;
      if (debugEnabled) {
        S_LOGGER.debug("configFilePath ... " + mailFilePath);
      }
      File mailFile = new File(mailFilePath);

      SvnProcessor processor = new SvnProcessor(mailFile);

      //			DataInputStream in = new DataInputStream(new FileInputStream(mailFile));
      //			while (in.available() != 0) {
      //				System.out.println(in.readLine());
      //			}
      //			in.close();

      // Mail have to go with jenkins running email address
      InetAddress ownIP = InetAddress.getLocalHost();
      processor.changeNodeValue(
          CI_HUDSONURL,
          HTTP_PROTOCOL
              + PROTOCOL_POSTFIX
              + ownIP.getHostAddress()
              + COLON
              + job.getJenkinsPort()
              + FORWARD_SLASH
              + CI
              + FORWARD_SLASH);
      processor.changeNodeValue("smtpAuthUsername", job.getSenderEmailId());
      processor.changeNodeValue("smtpAuthPassword", job.getSenderEmailPassword());
      processor.changeNodeValue("adminAddress", job.getSenderEmailId());

      // jenkins home location
      String jenkinsJobHome = System.getenv(JENKINS_HOME);
      StringBuilder builder = new StringBuilder(jenkinsJobHome);
      builder.append(File.separator);

      processor.writeStream(new File(builder.toString() + CI_MAILER_XML));
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into the catch block of CIManagerImpl.setMailCredential "
              + e.getLocalizedMessage());
    }
  }
  public static Map<String, Integer> queryTF(
      String word,
      Map<String, TokenCatalogBean> tokenCatBean,
      Map<String, DocBean> docCatBean,
      Utility u,
      String folder)
      throws IOException {

    Map<String, Integer> results = new HashMap<>();
    long startOffset = 0;
    long endOffset = 0;
    word = word.toLowerCase().trim();

    if (tokenCatBean.containsKey(word)) {
      // System.out.println("tokenCatBeanContains the word "+word);
      startOffset = tokenCatBean.get(word).getStartOffset();
      endOffset = tokenCatBean.get(word).getEndOffset();
      // System.out.println("StartOffset:: "+startOffset);
      // System.out.println("EndOffset:: "+endOffset);

      RandomAccessFile raf =
          new RandomAccessFile("C:\\Users\\Nitin\\Assign2\\" + folder + "\\TermsHash84.txt", "r");
      raf.seek(startOffset);
      byte[] termLine = new byte[(int) (endOffset - startOffset)];
      raf.read(termLine);
      String term = new String(termLine);
      // System.out.println("Term Fetched:::: "+term);

      String[] termOutput = term.split(" ");
      // System.out.println("last splitTerm"+
      // termOutput[termOutput.length-1]);

      for (int i = 1; i < termOutput.length - 1; i++) {

        String s = termOutput[i];
        // System.out.println("String output:: "+s);
        String[] docDetail = s.split(":");
        int docId = Integer.parseInt(docDetail[0]);
        int endIndex = docDetail[1].indexOf("-");
        int tF = Integer.parseInt(docDetail[1].substring(0, endIndex));
        results.put(u.getDocKey(docId), tF);
      }

      raf.close();
    }

    return results;
  }
Ejemplo n.º 29
0
  @Test
  public void new_fieldsTest() {
    int length = 10;
    String name = "td";
    Tuple t = new Tuple(Utility.getTupleDesc(length, name));

    Iterator<Field> fs = t.fields();

    int i = 0;
    while (fs.hasNext()) {
      i++;
      fs.next();
    }

    assertEquals(length, i);
  }
Ejemplo n.º 30
0
  public static void main(String[] args) {
    TreeMap<String, ArrayList<String>> topicToQuestionMap = Utility.getTopicToQuestionMap();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    PrintStream old = System.out;
    System.setOut(ps);

    JsonObject info = new JsonObject();
    Gson gson = new GsonBuilder().disableHtmlEscaping().create();
    for (Map.Entry<String, ArrayList<String>> entry : topicToQuestionMap.entrySet()) {
      String topic = entry.getKey();
      ArrayList<String> questions = entry.getValue();
      JsonObject quesToSol = new JsonObject();
      for (String question : questions) {
        baos.reset();
        question = question.split("\\.")[0];
        Class cls = null;
        try {
          cls = Class.forName(topic + "." + question);
        } catch (ClassNotFoundException e) {
          e.printStackTrace();
        }
        try {
          Method method = cls.getMethod("main", String[].class);
          method.invoke(null, new Object[] {new String[] {}});
        } catch (Exception e) {
          System.out.println("This is a helper class to be used by other programs.");
        }
        System.out.flush();
        String solution = baos.toString();
        quesToSol.addProperty(question, solution);
      }
      info.addProperty(topic, gson.toJson(quesToSol));
    }

    System.setOut(old);

    System.out.println(info);

    try (BufferedWriter writer = new BufferedWriter(new FileWriter(OUTPUT_FILE))) {
      writer.write(info.toString());
    } catch (IOException e) {
      e.printStackTrace();
    }
  }