當前位置: 首頁>>代碼示例>>Java>>正文


Java SystemUtils.LINE_SEPARATOR屬性代碼示例

本文整理匯總了Java中org.apache.commons.lang.SystemUtils.LINE_SEPARATOR屬性的典型用法代碼示例。如果您正苦於以下問題:Java SystemUtils.LINE_SEPARATOR屬性的具體用法?Java SystemUtils.LINE_SEPARATOR怎麽用?Java SystemUtils.LINE_SEPARATOR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.commons.lang.SystemUtils的用法示例。


在下文中一共展示了SystemUtils.LINE_SEPARATOR屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getStackFrameList

/**
 * <p>Produces a <code>List</code> of stack frames - the message
 * is not included. Only the trace of the specified exception is
 * returned, any caused by trace is stripped.</p>
 *
 * <p>This works in most cases - it will only fail if the exception
 * message contains a line that starts with:
 * <code>&quot;&nbsp;&nbsp;&nbsp;at&quot;.</code></p>
 * 
 * @param t is any throwable
 * @return List of stack frames
 */
static List getStackFrameList(Throwable t) {
    String stackTrace = getStackTrace(t);
    String linebreak = SystemUtils.LINE_SEPARATOR;
    StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
    List list = new ArrayList();
    boolean traceStarted = false;
    while (frames.hasMoreTokens()) {
        String token = frames.nextToken();
        // Determine if the line starts with <whitespace>at
        int at = token.indexOf("at");
        if (at != -1 && token.substring(0, at).trim().length() == 0) {
            traceStarted = true;
            list.add(token);
        } else if (traceStarted) {
            break;
        }
    }
    return list;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:31,代碼來源:ExceptionUtils.java

示例2: getStackFrameList

static List<String> getStackFrameList(Throwable t)
{
  String stackTrace = getStackTrace(t);
  String linebreak = SystemUtils.LINE_SEPARATOR;
  StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
  List<String> list = new ArrayList<String>();
  boolean traceStarted = false;
  while (frames.hasMoreTokens()) {
    String token = frames.nextToken();

    int at = token.indexOf("at");
    if ((at != -1) && (token.substring(0, at).trim().length() == 0)) {
      traceStarted = true;
      list.add(token); 
    } else {
      if (traceStarted)
        break;
    }
  }
  return list;
}
 
開發者ID:thinking-github,項目名稱:nbone,代碼行數:21,代碼來源:ExceptionUtils.java

示例3: writeWrapped

/**
 * Writes one or more lines of text, applying line wrapping.
 */
private void writeWrapped(final String text) {

  // Handle the case of multiple lines
  if (text.contains(SystemUtils.LINE_SEPARATOR)) {
    for (String line : text.split(SystemUtils.LINE_SEPARATOR)) {
      writeWrapped(line);
    }
    return;
  }

  // Write anything below the wrapping limit
  if (text.length() < LINE_LENGTH) {
    outputStream.println(text);
    return;
  }

  // Measure the indent to use on the split lines
  int indent = 0;
  while (indent < text.length() && text.charAt(indent) == ' ') {
    indent++;
  }
  indent += 2;

  // Split the line, preserving the indent on new lines
  final String firstLineIndent = text.substring(0, indent);
  final String lineSeparator = SystemUtils.LINE_SEPARATOR + StringUtils.repeat(" ", indent);
  outputStream.println(firstLineIndent + WordUtils.wrap(text.substring(indent), LINE_LENGTH - indent, lineSeparator, false));
}
 
開發者ID:alfasoftware,項目名稱:morf,代碼行數:31,代碼來源:ChangelogStatementConsumer.java

示例4: getStackFrames

static String[] getStackFrames(String stackTrace)
{
  String linebreak = SystemUtils.LINE_SEPARATOR;
  StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
  List<String> list = new ArrayList<String>();
  while (frames.hasMoreTokens()) {
    list.add(frames.nextToken());
  }
  return toArray(list);
}
 
開發者ID:thinking-github,項目名稱:nbone,代碼行數:10,代碼來源:ExceptionUtils.java

示例5: toString

@Override
public String toString() {
  return JOINER.join(keywords.values()) + SystemUtils.LINE_SEPARATOR;
}
 
開發者ID:googleads,項目名稱:keyword-optimizer,代碼行數:4,代碼來源:KeywordCollection.java

示例6: getStackFrames

/**
 * <p>Returns an array where each element is a line from the argument.</p>
 *
 * <p>The end of line is determined by the value of {@link SystemUtils#LINE_SEPARATOR}.</p>
 *
 * <p>Functionality shared between the
 * <code>getStackFrames(Throwable)</code> methods of this and the
 * {@link org.apache.commons.lang.exception.NestableDelegate} classes.</p>
 *
 * @param stackTrace  a stack trace String
 * @return an array where each element is a line from the argument
 */
static String[] getStackFrames(String stackTrace) {
    String linebreak = SystemUtils.LINE_SEPARATOR;
    StringTokenizer frames = new StringTokenizer(stackTrace, linebreak);
    List list = new ArrayList();
    while (frames.hasMoreTokens()) {
        list.add(frames.nextToken());
    }
    return toArray(list);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:ExceptionUtils.java


注:本文中的org.apache.commons.lang.SystemUtils.LINE_SEPARATOR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。