congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
FileWriter.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
java.io.FileWriter
constructor

Best Java code snippets using java.io.FileWriter.<init> (Showing top 20 results out of 35,730)

Refine searchRefine arrow

  • BufferedWriter.<init>
  • File.<init>
  • BufferedWriter.close
  • Writer.write
  • PrintWriter.<init>
  • BufferedWriter.write
canonical example by Tabnine

public void writeToFile(File dest, String content, boolean append) throws IOException {
  // append - true for writing to the end of the file rather to the beginning
  try (PrintWriter writer = new PrintWriter(new FileWriter(dest, append))) {
    writer.print(content);
  }
}
origin: Tencent/tinker

private void checkWriter() throws IOException {
  if (infoWrite == null) {
    this.infoWrite = new BufferedWriter(new FileWriter(infoFile, false));
  }
}
origin: stackoverflow.com

 try(FileWriter fw = new FileWriter("outfilename", true);
  BufferedWriter bw = new BufferedWriter(fw);
  PrintWriter out = new PrintWriter(bw))
{
  out.println("the text");
  //more code
  out.println("more text");
  //more code
} catch (IOException e) {
  //exception handling left as an exercise for the reader
}
origin: stanfordnlp/CoreNLP

public static void print(String[][] cols) throws Exception {
 BufferedWriter out = new BufferedWriter(new FileWriter(outputFilename));
 for (String[] col : cols) {
  if (col.length >= 2) {
   out.write(col[0] + "\t" + col[1] + "\n");
  } else {
   out.write("\n");
  }
 }
 out.flush();
 out.close();
}
origin: jenkinsci/jenkins

  @Override
  public String invoke(File dir, VirtualChannel channel) throws IOException {
    if(!inThisDirectory)
      dir = new File(System.getProperty("java.io.tmpdir"));
    else
      mkdirs(dir);
    File f;
    try {
      f = creating(File.createTempFile(prefix, suffix, dir));
    } catch (IOException e) {
      throw new IOException("Failed to create a temporary directory in "+dir,e);
    }
    try (Writer w = new FileWriter(writing(f))) {
      w.write(contents);
    }
    return f.getAbsolutePath();
  }
}
origin: stackoverflow.com

 File file = new File("C:\\user\\Desktop\\dir1\\dir2\\filename.txt");
file.getParentFile().mkdirs();
FileWriter writer = new FileWriter(file);
origin: Alluxio/alluxio

/**
 * @return the report file to save user-facing messages
 */
public static PrintWriter initReportFile() throws Exception {
 File file = new File("./IntegrationReport.txt");
 if (!file.exists()) {
  file.createNewFile();
 }
 FileWriter fileWriter = new FileWriter(file.getAbsoluteFile(), true);
 BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
 PrintWriter reportWriter = new PrintWriter(bufferedWriter);
 // Print the current time to separate integration checker results
 SimpleDateFormat df = new SimpleDateFormat("dd/MM/yy HH:mm:ss");
 Date date = new Date();
 reportWriter.printf("%n%n%n***** The integration checker ran at %s. *****%n%n",
   df.format(date));
 return reportWriter;
}
origin: log4j/log4j

protected void store(String s) {
 try {
  PrintWriter writer = new PrintWriter(new FileWriter(getFilename()));
  writer.print(s);
  writer.close();
 } catch (IOException e) {
  // do something with this error.
  e.printStackTrace();
 }
}
origin: stackoverflow.com

 try (
  FileWriter fw = new FileWriter(file);
  BufferedWriter bw = new BufferedWriter(fw)
) {
  bw.write(text);
}
origin: org.testng/testng

public static void writeFile(String string, File f) throws IOException {
 f.getParentFile().mkdirs();
 try (FileWriter fw = new FileWriter(f);
   BufferedWriter bw = new BufferedWriter(fw)) {
  bw.write(string);
 }
}
origin: stanfordnlp/CoreNLP

static public void writeColumnOutput(String outFile, boolean batchProcessSents, Map<String, Class<? extends TypesafeMap.Key<String>>> answerclasses) throws IOException, ClassNotFoundException {
 BufferedWriter writer = new BufferedWriter(new FileWriter(outFile));
 ConstantsAndVariables.DataSentsIterator sentsIter = new ConstantsAndVariables.DataSentsIterator(batchProcessSents);
 while(sentsIter.hasNext()){
  Pair<Map<String, DataInstance>, File> sentsf = sentsIter.next();
  writeColumnOutputSents(sentsf.first(), writer, answerclasses);
 }
 writer.close();
}
origin: stackoverflow.com

 import java.io.FileWriter;
FileWriter writer = new FileWriter("output.txt"); 
for(String str: arr) {
 writer.write(str);
}
writer.close();
origin: apache/storm

public static void writeToFile(File file, Set<String> content) throws IOException {
  FileWriter fw = new FileWriter(file, false);
  BufferedWriter bw = new BufferedWriter(fw);
  Iterator<String> iter = content.iterator();
  while (iter.hasNext()) {
    bw.write(iter.next());
    bw.write(System.lineSeparator());
  }
  bw.close();
}
origin: stackoverflow.com

 File myFoo = new File("foo.log");
FileWriter fooWriter = new FileWriter(myFoo, false); // true to append
                           // false to overwrite.
fooWriter.write("New Contents\n");
fooWriter.close();
origin: apache/flink

static FileWriter createOrGetFile(File folder, String name) throws IOException {
  File file = new File(folder, name + ".json");
  if (!file.exists()) {
    Files.createFile(file.toPath());
  }
  FileWriter fr = new FileWriter(file);
  return fr;
}
origin: apache/incubator-pinot

private void persistIndexMap(IndexEntry entry)
  throws IOException {
 File mapFile = new File(segmentDirectory, INDEX_MAP_FILE);
 try (PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(mapFile, true)))) {
  String startKey = getKey(entry.key.name, entry.key.type.getIndexName(), true);
  StringBuilder sb = new StringBuilder();
  sb.append(startKey).append(" = ").append(entry.startOffset);
  writer.println(sb.toString());
  String endKey = getKey(entry.key.name, entry.key.type.getIndexName(), false);
  sb = new StringBuilder();
  sb.append(endKey).append(" = ").append(entry.size);
  writer.println(sb.toString());
 }
}
origin: stackoverflow.com

 try {
  PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("myfile.txt", true)));
  out.println("the text");
  out.close();
} catch (IOException e) {
  //exception handling left as an exercise for the reader
}
origin: code4craft/webmagic

private void initWriter() {
  try {
    fileUrlWriter = new PrintWriter(new FileWriter(getFileName(fileUrlAllName), true));
    fileCursorWriter = new PrintWriter(new FileWriter(getFileName(fileCursor), false));
  } catch (IOException e) {
    throw new RuntimeException("init cache scheduler error", e);
  }
}
origin: stackoverflow.com

 try (FileWriter fw = new FileWriter(file)) {
  BufferedWriter bw = new BufferedWriter(fw);
  bw.write(text);
}
origin: stanfordnlp/CoreNLP

@Override
public void saveToFilename(String file) {
 try (BufferedWriter bw = new BufferedWriter(new FileWriter(file))) {
  for (int i = 0, sz = size(); i < sz; i++) {
   bw.write(i + "=" + get(i) + '\n');
  }
 } catch (IOException e) {
  throw new RuntimeIOException(e);
 }
 // give up
}
java.ioFileWriter<init>

Javadoc

Creates a FileWriter using the File file.

Popular methods of FileWriter

  • close
  • write
  • flush
  • append
  • getEncoding

Popular in Java

  • Updating database using SQL prepared statement
  • requestLocationUpdates (LocationManager)
  • setContentView (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Github Copilot alternatives
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