congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
BufferedWriter.newLine
Code IndexAdd Tabnine to your IDE (free)

How to use
newLine
method
in
java.io.BufferedWriter

Best Java code snippets using java.io.BufferedWriter.newLine (Showing top 20 results out of 8,217)

Refine searchRefine arrow

  • BufferedWriter.close
  • BufferedWriter.<init>
  • FileWriter.<init>
  • BufferedWriter.write
  • Writer.write
  • File.<init>
origin: oblac/jodd

  private void writeBaseProperty(final BufferedWriter bw, final String key, final String value)
      throws IOException {
    bw.write(key + '=' + value);
    bw.newLine();
  }
}
origin: apache/storm

public static void writeFileByLine(String filePath, List<String> linesToWrite) throws IOException {
  LOG.debug("For CGroups - writing {} to {} ", linesToWrite, filePath);
  File file = new File(filePath);
  if (!file.exists()) {
    LOG.error("{} does not exist", filePath);
    return;
  }
  try (FileWriter writer = new FileWriter(file, true);
     BufferedWriter bw = new BufferedWriter(writer)) {
    for (String string : linesToWrite) {
      bw.write(string);
      bw.newLine();
      bw.flush();
    }
  }
}
origin: FudanNLP/fnlp

/**
 * 将Map写到文件
 * @param map
 * @throws IOException 
 */
public static void write(Map map,String file) throws IOException {
  BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(
      new FileOutputStream(file), "UTF-8"));
  Iterator iterator = map.entrySet().iterator();
  while (iterator.hasNext()) {
    Map.Entry entry = (Map.Entry)iterator.next();
    String key = entry.getKey().toString();
    String v = entry.getValue().toString();
    bout.append(key);
    bout.append("\t");
    bout.append(v);
    bout.newLine();
  }
  bout.close();
}
origin: stackoverflow.com

 String encoding = "UTF-8";
int maxlines = 100;
BufferedReader reader = null;
BufferedWriter writer = null;

try {
  reader = new BufferedReader(new InputStreamReader(new FileInputStream("/bigfile.txt"), encoding));
  int count = 0;
  for (String line; (line = reader.readLine()) != null;) {
    if (count++ % maxlines == 0) {
      close(writer);
      writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("/smallfile" + (count / maxlines) + ".txt"), encoding));
    }
    writer.write(line);
    writer.newLine();
  }
} finally {
  close(writer);
  close(reader);
}
origin: org.codehaus.groovy/groovy

public Writer writeTo(Writer out) throws IOException {
  BufferedWriter bw = new BufferedWriter(out);
  String line;
  BooleanClosureWrapper bcw = new BooleanClosureWrapper(closure);
  while ((line = br.readLine()) != null) {
    if (bcw.call(line)) {
      bw.write(line);
      bw.newLine();
    }
  }
  bw.flush();
  return out;
}
origin: hankcs/HanLP

/**
 * 标准化评测分词器
 *
 * @param segment    分词器
 * @param outputPath 分词预测输出文件
 * @param goldFile   测试集segmented file
 * @param dictPath   训练集单词列表
 * @return 一个储存准确率的结构
 * @throws IOException
 */
public static CWSEvaluator.Result evaluate(Segment segment, String outputPath, String goldFile, String dictPath) throws IOException
{
  IOUtil.LineIterator lineIterator = new IOUtil.LineIterator(goldFile);
  BufferedWriter bw = IOUtil.newBufferedWriter(outputPath);
  for (String line : lineIterator)
  {
    List<Term> termList = segment.seg(line.replaceAll("\\s+", "")); // 一些testFile与goldFile根本不匹配,比如MSR的testFile有些行缺少单词,所以用goldFile去掉空格代替
    int i = 0;
    for (Term term : termList)
    {
      bw.write(term.word);
      if (++i != termList.size())
        bw.write("  ");
    }
    bw.newLine();
  }
  bw.close();
  CWSEvaluator.Result result = CWSEvaluator.evaluate(goldFile, outputPath, dictPath);
  return result;
}
origin: stackoverflow.com

 public void appendLog(String text)
{       
  File logFile = new File("sdcard/log.file");
  if (!logFile.exists())
  {
   try
   {
     logFile.createNewFile();
   } 
   catch (IOException e)
   {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
  }
  try
  {
   //BufferedWriter for performance, true to set append to file flag
   BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true)); 
   buf.append(text);
   buf.newLine();
   buf.close();
  }
  catch (IOException e)
  {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
}
origin: stackoverflow.com

BufferedWriter bufOut = new BufferedWriter( new OutputStreamWriter( out ) );
while ( true ) {
  try {
    String msg = bufIn.readLine();
    System.out.println( "Received: " + msg );
    bufOut.write( msg );
    bufOut.newLine(); //HERE!!!!!!
    bufOut.flush();
  } catch ( IOException e ) {
origin: oblac/jodd

private void writeProfileProperty(final BufferedWriter bw, final String profileName,
                 final String key, final String value)
    throws IOException {
  bw.write(key + '<' + profileName + '>' + '=' + value);
  bw.newLine();
}
origin: apache/storm

private void updateIndex(long txId) {
  LOG.debug("Starting index update.");
  final Path tmpPath = tmpFilePath(indexFilePath.toString());
  try (FSDataOutputStream out = this.options.fs.create(tmpPath, true);
     BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out))) {
    TxnRecord txnRecord = new TxnRecord(txId, options.currentFile.toString(), this.options.getCurrentOffset());
    bw.write(txnRecord.toString());
    bw.newLine();
    bw.flush();
    out.close();       /* In non error scenarios, for the Azure Data Lake Store File System (adl://),
              the output stream must be closed before the file associated with it is deleted.
              For ADLFS deleting the file also removes any handles to the file, hence out.close() will fail. */
    /*
     * Delete the current index file and rename the tmp file to atomically
     * replace the index file. Orphan .tmp files are handled in getTxnRecord.
     */
    options.fs.delete(this.indexFilePath, false);
    options.fs.rename(tmpPath, this.indexFilePath);
    lastSeenTxn = txnRecord;
    LOG.debug("updateIndex updated lastSeenTxn to [{}]", this.lastSeenTxn);
  } catch (IOException e) {
    LOG.warn("Begin commit failed due to IOException. Failing batch", e);
    throw new FailedException(e);
  }
}
origin: apache/incubator-druid

 for (int j = 0; j < 20; j++) {
  double value = rand.nextDouble();
  buildData.write("2016010101");
  buildData.write('\t');
  buildData.write(Integer.toString(sequenceNumber)); // dimension with unique numbers for ingesting raw data
  buildData.write('\t');
  buildData.write(Integer.toString(product)); // product dimension
  buildData.write('\t');
  buildData.write(Double.toString(value));
  buildData.newLine();
  sketch.update(value);
  sequenceNumber++;
 sketchData.write('\t');
 sketchData.write(StringUtils.encodeBase64String(sketch.toByteArray(true)));
 sketchData.newLine();
buildData.close();
sketchData.close();
origin: stackoverflow.com

 public static void main(String[] args) throws Exception {
  String nodeValue = "i am mostafa";

  // you want to output to file
  // BufferedWriter writer = new BufferedWriter(new FileWriter(file3, true));
  // but let's print to console while debugging
  BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

  String[] words = nodeValue.split(" ");
  for (String word: words) {
    writer.write(word);
    writer.newLine();
  }
  writer.close();
}
origin: stackoverflow.com

try {
  Socket s = new Socket("localhost", 60010);
  BufferedWriter out = new BufferedWriter(
      new OutputStreamWriter(s.getOutputStream()));
    out.write("Hello World!");
    out.newLine();
    out.flush();
origin: apache/flink

private static void writePoint(double[] coordinates, StringBuilder buffer, BufferedWriter out) throws IOException {
  buffer.setLength(0);
  // write coordinates
  for (int j = 0; j < coordinates.length; j++) {
    buffer.append(FORMAT.format(coordinates[j]));
    if (j < coordinates.length - 1) {
      buffer.append(DELIMITER);
    }
  }
  out.write(buffer.toString());
  out.newLine();
}
origin: stackoverflow.com

 public void stripDuplicatesFromFile(String filename) {
  BufferedReader reader = new BufferedReader(new FileReader(filename));
  Set<String> lines = new HashSet<String>(10000); // maybe should be bigger
  String line;
  while ((line = reader.readLine()) != null) {
    lines.add(line);
  }
  reader.close();
  BufferedWriter writer = new BufferedWriter(new FileWriter(filename));
  for (String unique : lines) {
    writer.write(unique);
    writer.newLine();
  }
  writer.close();
}
origin: apache/flink

  private static void writePoint(double[] data, StringBuilder buffer, BufferedWriter out) throws IOException {
    buffer.setLength(0);

    // write coordinates
    for (int j = 0; j < data.length; j++) {
      buffer.append(FORMAT.format(data[j]));
      if (j < data.length - 1) {
        buffer.append(DELIMITER);
      }
    }

    out.write(buffer.toString());
    out.newLine();
  }
}
origin: apache/geode

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();
}
origin: hankcs/HanLP

@Override
protected void convertCorpus(Sentence sentence, BufferedWriter bw) throws IOException
{
  List<String[]> collector = Utility.convertSentenceToNER(sentence, tagSet);
  for (String[] tuple : collector)
  {
    bw.write(tuple[0]);
    bw.write('\t');
    bw.write(tuple[1]);
    bw.write('\t');
    bw.write(tuple[2]);
    bw.newLine();
  }
}
origin: apache/geode

 public static void storeClassesAndVariables(List<ClassAndVariables> cams, File file)
   throws IOException {
  FileWriter fw = new FileWriter(file);
  BufferedWriter out = new BufferedWriter(fw);
  for (ClassAndVariables entry : cams) {
   out.append(ClassAndVariableDetails.convertForStoring(entry));
   out.newLine();
  }
  out.flush();
  out.close();
 }
}
origin: apache/flink

  private static void writeCenter(long id, double[] coordinates, StringBuilder buffer, BufferedWriter out) throws IOException {
    buffer.setLength(0);

    // write id
    buffer.append(id);
    buffer.append(DELIMITER);

    // write coordinates
    for (int j = 0; j < coordinates.length; j++) {
      buffer.append(FORMAT.format(coordinates[j]));
      if (j < coordinates.length - 1) {
        buffer.append(DELIMITER);
      }
    }

    out.write(buffer.toString());
    out.newLine();
  }
}
java.ioBufferedWriternewLine

Javadoc

Writes a newline to this writer. On Android, this is "\n". The target writer may or may not be flushed when a newline is written.

Popular methods of BufferedWriter

  • <init>
    Constructs a new BufferedWriter, providing out with size chars of buffer.
  • write
    Writes count characters starting at offset in buffer to this writer. If count is greater than this w
  • close
    Closes this writer. The contents of the buffer are flushed, the target writer is closed, and the buf
  • flush
    Flushes this writer. The contents of the buffer are committed to the target writer and it is then fl
  • append
  • checkNotClosed
  • flushInternal
    Flushes the internal buffer.
  • isClosed
    Indicates whether this writer is closed.
  • drain
  • ensureOpen
    Checks to make sure that the stream has not been closed
  • flushBuffer
    Flushes the output buffer to the underlying character stream, without flushing the stream itself. Th
  • min
    Our own little min method, to avoid loading java.lang.Math if we've run out of file descriptors and
  • flushBuffer,
  • min

Popular in Java

  • Parsing JSON documents to java classes using gson
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • scheduleAtFixedRate (Timer)
  • getSystemService (Context)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now