本文整理汇总了Java中java.io.BufferedWriter.newLine方法的典型用法代码示例。如果您正苦于以下问题:Java BufferedWriter.newLine方法的具体用法?Java BufferedWriter.newLine怎么用?Java BufferedWriter.newLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.BufferedWriter
的用法示例。
在下文中一共展示了BufferedWriter.newLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: battleLogger
import java.io.BufferedWriter; //导入方法依赖的package包/类
public static void battleLogger(String str) {
String path = File.separator + "BattleLog.txt";
File file = new File(path);
try {
FileWriter fw = new FileWriter(file.getName(), true);
BufferedWriter bw = new BufferedWriter(fw);
Date now = new Date();
bw.write(DateFormat.getDateInstance(DateFormat.SHORT).format(now) + " " + DateFormat.getTimeInstance().format(now) + " - " + str);
bw.newLine();
bw.flush();
bw.close();
} catch (Exception e) {
System.out.println("Battle log failure");
}
}
示例2: writeFile
import java.io.BufferedWriter; //导入方法依赖的package包/类
/**
* write cofiguration
* @return
* @throws IOException
*/
private File writeFile() throws IOException {
File f = new File(testDir, "tst.xml");
BufferedWriter out = new BufferedWriter(new FileWriter(f));
String properties = "<properties><property key=\"key\" value=\"value\"/><property key=\"key1\" value=\"value1\"/></properties>";
out.write("<queues>");
out.newLine();
out.write("<queue><name>first</name><acl-submit-job>user1,user2 group1,group2</acl-submit-job><acl-administer-jobs>user3,user4 group3,group4</acl-administer-jobs><state>running</state></queue>");
out.newLine();
out.write("<queue><name>second</name><acl-submit-job>u1,u2 g1,g2</acl-submit-job>"
+ properties + "<state>stopped</state></queue>");
out.newLine();
out.write("</queues>");
out.flush();
out.close();
return f;
}
示例3: log2File
import java.io.BufferedWriter; //导入方法依赖的package包/类
/**
* 打开日志文件并写入日志
*
* @return
**/
private synchronized static void log2File(String mylogtype, String tag, String text) {
Date nowtime = new Date();
String date = FILE_SUFFIX.format(nowtime);
String dateLogContent = LOG_FORMAT.format(nowtime) + ":" + mylogtype + ":" + tag + ":" + text; // 日志输出格式
File destDir = new File(LOG_FILE_PATH);
if (!destDir.exists()) {
destDir.mkdirs();
}
File file = new File(LOG_FILE_PATH, LOG_FILE_NAME + date);
try {
FileWriter filerWriter = new FileWriter(file, true);
BufferedWriter bufWriter = new BufferedWriter(filerWriter);
bufWriter.write(dateLogContent);
bufWriter.newLine();
bufWriter.close();
filerWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例4: save
import java.io.BufferedWriter; //导入方法依赖的package包/类
public void save(OutputStream outStream, boolean sorted) throws IOException {
if (!sorted) {
save(outStream);
return;
}
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outStream, "UTF-8"));
String aKey;
Object aValue;
TreeMap tm = new TreeMap(this);
for (Iterator i = tm.keySet().iterator(); i.hasNext();) {
aKey = (String) i.next();
aValue = get(aKey);
out.write(aKey + " = " + aValue);
out.newLine();
}
out.flush();
out.close();
}
示例5: testExtract
import java.io.BufferedWriter; //导入方法依赖的package包/类
public void testExtract() throws Exception
{
List<File> fileList = FolderWalker.open(FOLDER);
Map<String, String> phraseMap = new TreeMap<String, String>();
int i = 0;
for (File file : fileList)
{
System.out.print(++i + " / " + fileList.size() + " " + file.getName() + " ");
String path = file.getAbsolutePath();
List<String> phraseList = MutualInformationEntropyPhraseExtractor.extract(IOUtil.readTxt(path), 3);
System.out.print(phraseList);
for (String phrase : phraseList)
{
phraseMap.put(phrase, file.getAbsolutePath());
}
System.out.println();
}
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("data/phrase.txt")));
for (Map.Entry<String, String> entry : phraseMap.entrySet())
{
bw.write(entry.getKey() + "\t" + entry.getValue());
bw.newLine();
}
bw.close();
}
示例6: store0
import java.io.BufferedWriter; //导入方法依赖的package包/类
private void store0(BufferedWriter bw, String comments, boolean escUnicode)
throws IOException
{
if (comments != null) {
writeComments(bw, comments);
}
bw.write("#" + new Date().toString());
bw.newLine();
synchronized (this) {
for (Map.Entry<Object, Object> e : entrySet()) {
String key = (String)e.getKey();
String val = (String)e.getValue();
key = saveConvert(key, true, escUnicode);
/* No need to escape embedded and trailing spaces for value, hence
* pass false to flag.
*/
val = saveConvert(val, false, escUnicode);
bw.write(key + "=" + val);
bw.newLine();
}
}
bw.flush();
}
示例7: save
import java.io.BufferedWriter; //导入方法依赖的package包/类
public void save(OutputStream outStream) throws IOException {
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outStream, "UTF-8"));
String aKey;
Object aValue;
for (Enumeration e = keys(); e.hasMoreElements();) {
aKey = (String) e.nextElement();
aValue = get(aKey);
out.write(aKey + " = " + aValue);
out.newLine();
}
out.flush();
out.close();
}
示例8: writeQValues
import java.io.BufferedWriter; //导入方法依赖的package包/类
public static void writeQValues(File outputFile, String description, List<Double> qValuesReal, List<Double> qValuesPred)throws Exception{
if(!outputFile.getParentFile().exists())outputFile.getParentFile().mkdirs();
BufferedWriter bw=new BufferedWriter(new FileWriter(outputFile));
bw.write(description);
bw.newLine();
bw.write("calculated qValue\testimated qValue");
bw.newLine();
double sum=0;
int n=0;
for(int i=0;i<qValuesReal.size();i++){
sum+=qValuesPred.get(i);
n+=1;
if(i==qValuesReal.size()-1||Double.compare(qValuesReal.get(i+1),qValuesReal.get(i))!=0){
bw.write(qValuesReal.get(i)+"\t"+sum/n);
bw.newLine();
n=0;
sum=0;
}
}
bw.close();
}
示例9: writePrefix
import java.io.BufferedWriter; //导入方法依赖的package包/类
private void writePrefix(BufferedWriter writer) throws IOException {
writer.append("<!DOCTYPE html>");
writer.newLine();
writer.append("<html lang=\"en\">");
writer.newLine();
writer.append("<head>");
writer.newLine();
writer.append(" <meta charset=\"utf-8\" />");
writer.newLine();
writer.append(" <title>uroboroSQL code coverage report for ").append(this.name).append("</title>");
writer.newLine();
writer.append(" <link rel=\"stylesheet\" href=\"").append(getAssetPath()).append("/style.css\">");
writer.newLine();
writer.append(" <script src=\"").append(getAssetPath()).append("/jquery-3.2.0.min.js\"></script>");
writer.newLine();
writer.append(" <script src=\"").append(getAssetPath()).append("/highlight.pack.js\"></script>");
writer.newLine();
writer.append(" <script src=\"").append(getAssetPath()).append("/sqlcov.js\"></script>");
writer.newLine();
writer.append("</head>");
writer.newLine();
writer.append("<body>");
writer.newLine();
}
示例10: writeComments
import java.io.BufferedWriter; //导入方法依赖的package包/类
private static void writeComments(BufferedWriter bw, String comments)
throws IOException {
bw.write("#");
int len = comments.length();
int current = 0;
int last = 0;
char[] uu = new char[6];
uu[0] = '\\';
uu[1] = 'u';
while (current < len) {
char c = comments.charAt(current);
if (c > '\u00ff' || c == '\n' || c == '\r') {
if (last != current)
bw.write(comments.substring(last, current));
if (c > '\u00ff') {
uu[2] = toHex((c >> 12) & 0xf);
uu[3] = toHex((c >> 8) & 0xf);
uu[4] = toHex((c >> 4) & 0xf);
uu[5] = toHex( c & 0xf);
bw.write(new String(uu));
} else {
bw.newLine();
if (c == '\r' &&
current != len - 1 &&
comments.charAt(current + 1) == '\n') {
current++;
}
if (current == len - 1 ||
(comments.charAt(current + 1) != '#' &&
comments.charAt(current + 1) != '!'))
bw.write("#");
}
last = current + 1;
}
current++;
}
if (last != current)
bw.write(comments.substring(last, current));
bw.newLine();
}
示例11: createDefaultDbProperties
import java.io.BufferedWriter; //导入方法依赖的package包/类
private static void createDefaultDbProperties(String path) throws IOException{
File file = new File(path);
if(!file.getParentFile().exists()){
file.getParentFile().mkdirs();
}
file.createNewFile();
FileWriter fw = new FileWriter(file);
BufferedWriter write = new BufferedWriter(fw);
write.write("mail.transport.protocol=");
write.newLine();
write.write("mail.smtp.port=");
write.newLine();
write.write("mail.smtp.host=");
write.newLine();
write.write("mail.smtp.username=");
write.newLine();
write.write("mail.smtp.password=");
write.newLine();
write.write("mail.smtp.connectiontimeout=");
write.newLine();
write.write("mail.smtp.timeout=");
write.newLine();
write.write("mail.smtp.auth=");
write.flush();
write.close();
fw.close();
}
示例12: printThreadInfo
import java.io.BufferedWriter; //导入方法依赖的package包/类
private void printThreadInfo(Thread t, String indent, BufferedWriter w) throws IOException
{
if (t == null){
return;
}
w.write(indent + "Thread: " + t.getName() + " Priority: "
+ t.getPriority() + (t.isDaemon() ? " Daemon" : "")
+ (t.isAlive() ? "" : " Not Alive"));
w.newLine();
}
示例13: generateFile
import java.io.BufferedWriter; //导入方法依赖的package包/类
public static void generateFile(World world, int x, int y, int z, String path) {
try {
BufferedWriter bw = new BufferedWriter(new FileWriter(new File(path)));
for (int i = 0; i < 58; i++)
for (int j = 0; j < 31 - 9; j++)
for (int k = 0; k < 58; k++) {
Block b = world.getBlock(x + i, y + j, z + k);
int meta = world.getBlockMetadata(x + i, y + j, z + k);
String s = "(" + i + ", " + j + ", " + k + ") - ";
if (b == ModBlocks.prismarine)
s += meta;
else if (b == ModBlocks.sea_lantern)
s += 3;
else if (b == Blocks.gold_block)
s += 4;
else if (b == Blocks.sponge)
s += 5;
else if (b == Blocks.stained_glass)
s += 6;
else
s = null;
if (s != null) {
bw.write(s);
bw.newLine();
}
}
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例14: storeClassesAndMethods
import java.io.BufferedWriter; //导入方法依赖的package包/类
public static void storeClassesAndMethods(List<ClassAndMethods> cams, File file)
throws IOException {
FileWriter fw = new FileWriter(file);
BufferedWriter out = new BufferedWriter(fw);
for (ClassAndMethods entry : cams) {
out.append(ClassAndMethodDetails.convertForStoring(entry));
out.newLine();
}
out.flush();
out.close();
}
示例15: body
import java.io.BufferedWriter; //导入方法依赖的package包/类
public static void body(BufferedWriter wrlatex, List<Section> listSections, String referenceLink) throws IOException {
for (int j = 0; j < listSections.size(); j++) {
Section section = listSections.get(j);
sectionWriting(wrlatex, section);
} //end of Sections
wrlatex.newLine();
wrlatex.write("\\bibliography{");
wrlatex.write(referenceLink);
wrlatex.write("}");
wrlatex.newLine();
wrlatex.write("\\end{document}");
wrlatex.close();
}