@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
  @Nullable
  public static String getFileText(String parentDir, String fileName, boolean wrapHTML) {

    File inputFile = parentDir != null ? new File(parentDir, fileName) : new File(fileName);
    if (!inputFile.exists()) return null;
    StringBuilder taskText = new StringBuilder();
    BufferedReader reader = null;
    try {
      reader = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile)));
      String line;
      while ((line = reader.readLine()) != null) {
        taskText.append(line).append("\n");
        if (wrapHTML) {
          taskText.append("<br>");
        }
      }
      return wrapHTML ? UIUtil.toHtml(taskText.toString()) : taskText.toString();
    } catch (IOException e) {
      LOG.info("Failed to get file text from file " + fileName, e);
    } finally {
      closeSilently(reader);
    }
    return null;
  }
示例#2
0
 private void showMessageLabel(final String text) {
   myMessageLabel.setText(UIUtil.toHtml(text));
   myPropertiesPanelLayout.show(myPropertiesPanel, MESSAGE_CARD);
 }