本文整理匯總了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();
}