本文整理汇总了Java中org.apache.commons.lang3.text.StrBuilder.appendln方法的典型用法代码示例。如果您正苦于以下问题:Java StrBuilder.appendln方法的具体用法?Java StrBuilder.appendln怎么用?Java StrBuilder.appendln使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.text.StrBuilder
的用法示例。
在下文中一共展示了StrBuilder.appendln方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendXMLHttpGETRequest
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
public JsonElement sendXMLHttpGETRequest( final String url, final boolean async )
{
( ( EventFiringWebDriver ) driver ).manage().timeouts().setScriptTimeout( 20, TimeUnit.SECONDS );
StrBuilder builder = new StrBuilder( "var callback = arguments[arguments.length - 1];\n" );
builder.appendln( "var xhr = new XMLHttpRequest();" );
builder.append( "xhr.open( 'GET', '" ).append( url ).append( "', '" ).append( async ).append( "' );" );
builder.appendln( "xhr.onreadystatechange = function() { " );
builder.appendln( " if (xhr.readyState == 4) { " );
builder.appendln( " callback(xhr.responseText);" );
builder.appendln( " }" );
builder.appendln( "}" );
builder.appendln( "xhr.send();" );
Object response = executeAsyncScript( builder.toString() );
Gson gson = new Gson();
return gson.fromJson( ( String ) response, JsonElement.class );
}
示例2: parseMultipart
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
private static void parseMultipart(final StrBuilder sb, final Multipart multipart) throws MessagingException, IOException {
for (int i = 0; i < multipart.getCount(); i++) {
BodyPart bodyPart = multipart.getBodyPart(i);
String disposition = bodyPart.getDisposition();
if (disposition == null && bodyPart instanceof MimeBodyPart) { // not an attachment
MimeBodyPart mimeBodyPart = (MimeBodyPart) bodyPart;
if (mimeBodyPart.getContent() instanceof Multipart) {
parseMultipart(sb, (Multipart) mimeBodyPart.getContent());
} else {
String body = (String) mimeBodyPart.getContent();
sb.appendln(body);
sb.appendln("");
}
}
}
}
示例3: logProcessOutput
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
/**
* Logs the output of the specified process.
*
* @param p the process
* @throws IOException if an I/O problem occurs
*/
private static void logProcessOutput(Process p) throws IOException
{
try (BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())))
{
StrBuilder builder = new StrBuilder();
String line;
while ((line = input.readLine()) != null)
{
builder.appendln(line);
}
logger.info(builder.toString());
}
}
示例4: assemble
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
private String assemble() throws UserscriptBuilderException {
StrBuilder builder = new StrBuilder();
builder.appendln("// ==UserScript==");
appendValid(builder, "// @name ", userscript.getMetadata().getName());
appendValid(builder, "// @namespace ", userscript.getMetadata().getNamespace());
appendValid(builder, "// @description ", userscript.getMetadata().getDescription());
appendValid(builder, "// @version ", userscript.getMetadata().getVersion());
appendValid(builder, "// @author ", userscript.getMetadata().getAuthor());
appendValid(builder, "// @include ", userscript.getMetadata().getIncludes());
appendValid(builder, "// @exclude ", userscript.getMetadata().getExcludes());
appendValid(builder, "// @match ", userscript.getMetadata().getMatches());
appendValid(builder, "// @require ", userscript.getMetadata().getRequires());
appendValid(builder, "// @resource ", userscript.getMetadata().getResources());
appendValid(builder, "// @grant ", userscript.getMetadata().getGrants());
appendValid(builder, "// @noframes ", userscript.getMetadata().isNoFrames());
appendValid(builder, "// @run-at ", userscript.getMetadata().getRunAt());
appendValid(builder, "// @icon ", userscript.getMetadata().getIcon());
appendValid(builder, "// @downloadURL ", userscript.getMetadata().getDownloadURL());
appendValid(builder, "// @updateURL ", userscript.getMetadata().getUpdateURL());
builder.appendln("// ==/UserScript==");
builder.appendNewLine();
File sourceFile = new File(mojo.getSourceDirectory(), userscript.getSource());
String source;
try {
source = FileUtils.readFileToString(sourceFile);
} catch (IOException e) {
throw new UserscriptBuilderException("Could not read sourceFile: " + sourceFile.getPath(), e);
}
builder.append(filterSource(source));
return builder.build();
}
示例5: logProcessOutput
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
/**
* Logs the output of the specified process.
*
* @param p the process
* @throws IOException if an I/O problem occurs
*/
private static void logProcessOutput(Process p) throws IOException
{
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
StrBuilder builder = new StrBuilder();
String line;
while ((line = input.readLine()) != null)
{
builder.appendln(line);
}
logger.info(builder.toString());
}
示例6: archiveMessage
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
/**
* Saves a message's test content (including headers) in the current module archive in the specified sub-directory relative to
* the archive root. File names are prefixed with a left-padded four-digit integer counter (format: {@code %04d_%s.txt}).
*
* @param message
* the message
* @return the file the e-mail was written to
*/
public File archiveMessage(final MailMessage message) {
try {
String subject = message.getSubject();
String fileName = subject == null
? "no_subject"
: INVALID_FILE_NAME_CHARS.matcher(subject).replaceAll("_");
MutableInt counter = counterProvider.get();
File dir = new File("e-mails", "unread");
File file = new File(dir, String.format(FILE_NAME_FORMAT, counter.intValue(), fileName));
file = new File(moduleArchiveDirProvider.get(), file.getPath());
createParentDirs(file);
log.debug("Archiving e-mail: {}", file);
StrBuilder sb = new StrBuilder(500);
for (Entry<String, String> header : message.getHeaders().entries()) {
sb.append(header.getKey()).append('=').appendln(header.getValue());
}
sb.appendln("");
sb.append(message.getText());
write(sb.toString(), file, Charsets.UTF_8);
counter.increment();
return file;
} catch (IOException ex) {
throw new MailException("Error archiving mail.", ex);
}
}
示例7: createTable
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
private boolean createTable(Table table) {
final String methodName = "createTable";
StrBuilder sql = new StrBuilder();
sql.append(String.format("CREATE TABLE %s (", table.getName()));
boolean isFirst = true;
for(Column column : table.getColumns()) {
String name = column.getName();
String type = column.getType().toString().toUpperCase();
//short length = column.getLength();
if(!isFirst)
sql.appendln(",");
else
isFirst = false;
switch(type) {
case "BYTE":
case "INT":
case "LONG":
if(column.isAutoNumber()) {
sql.append(String.format("%s INTEGER PRIMARY KEY AUTOINCREMENT", name));
} else {
sql.append(String.format("%s INT NOT NULL DEFAULT 0", name));
}
break;
case "FLOAT":
sql.append(String.format("%s FLOAT NOT NULL DEFAULT 0", name));
break;
case "DOUBLE":
sql.append(String.format("%s DOUBLE NOT NULL DEFAULT 0", name));
break;
case "NUMERIC":
sql.append(String.format("%s DECIMAL(28,0) NOT NULL DEFAULT 0", name));
break;
case "MONEY":
sql.append(String.format("%s DECIMAL(15,4) NOT NULL DEFAULT 0", name));
break;
case "BOOLEAN":
sql.append(String.format("%s TINYINT NOT NULL DEFAULT 0", name));
break;
case "SHORT_DATE_TIME":
sql.append(String.format("%s DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'", name));
break;
case "MEMO":
sql.append(String.format("%s TEXT", name));
break;
case "GUID":
sql.append(String.format("%s VARCHAR(50) DEFAULT '{00000000-0000-0000-0000-000000000000}'", name));
break;
case "TEXT":
default:
sql.append(String.format("%s VARCHAR(255) DEFAULT ''", name));
break;
}
}
sql.append(")");
try {
try (Statement statement = connection.createStatement()) {
statement.executeUpdate(sql.build());
}
return true;
} catch (SQLException e) {
//lastError.add(String.format("Could not create table '%s'", table.getName()));
//AccessConverter.Error(String.format("Could not create table '%s'", table.getName()));
Error(String.format("Could not create table '%s'", table.getName()), e, methodName);
return false;
}
}
示例8: summary
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
public static String summary(JavaRDD<Tuple2<Object, Object>> scoreAndLabels, final long testCount) {
StrBuilder sb = new StrBuilder();
// Get evaluation metrics.
BinaryClassificationMetrics metrics = new BinaryClassificationMetrics(JavaRDD.toRDD(scoreAndLabels));
long correct = scoreAndLabels.filter(pl -> pl._1().equals(pl._2())).count();
double accuracy = (double) correct / testCount;
// AUPRC
double areaUnderPR = metrics.areaUnderPR();
// AUROC
double areaUnderROC = metrics.areaUnderROC();
// Precision by threshold
List<Tuple2<Object, Object>> precision = metrics.precisionByThreshold().toJavaRDD().collect();
// Recall by threshold
List<Tuple2<Object, Object>> recall = metrics.recallByThreshold().toJavaRDD().collect();
// F Score by threshold
List<Tuple2<Object, Object>> f1Score = metrics.fMeasureByThreshold().toJavaRDD().collect();
List<Tuple2<Object, Object>> f2Score = metrics.fMeasureByThreshold(2.0).toJavaRDD().collect();
// Precision-recall curve
List<Tuple2<Object, Object>> prc = metrics.pr().toJavaRDD().collect();
// Thresholds
List<Double> thresholds = metrics.precisionByThreshold().toJavaRDD().map(t -> new Double(t._1().toString()))
.collect();
// ROC Curve
List<Tuple2<Object, Object>> roc = metrics.roc().toJavaRDD().collect();
sb.appendln("ROC curve: " + roc);
sb.appendln("Precision by threshold: " + precision);
sb.appendln("Recall by threshold: " + recall);
sb.appendln("F1 Score by threshold: " + f1Score);
sb.appendln("F2 Score by threshold: " + f2Score);
sb.appendln("Precision-recall curve: " + prc);
sb.appendln("Thresholds: " + thresholds);
sb.appendln("Area under precision-recall curve = " + areaUnderPR);
sb.appendln("Area under ROC = " + areaUnderROC);
sb.appendln("Accuracy: " + accuracy * 100);
return sb.toString();
}
示例9: appendValid
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
private void appendValid(StrBuilder builder, String input, boolean condition) {
if (condition) {
builder.appendln(input);
}
}