<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FFile%2FBufferedOutputStream</id>
		<title>Java Tutorial/File/BufferedOutputStream - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FFile%2FBufferedOutputStream"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/File/BufferedOutputStream&amp;action=history"/>
		<updated>2026-04-25T05:31:18Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_Tutorial/File/BufferedOutputStream&amp;diff=5360&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/File/BufferedOutputStream&amp;diff=5360&amp;oldid=prev"/>
				<updated>2010-06-01T05:19:52Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 05:19, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_Tutorial/File/BufferedOutputStream&amp;diff=5359&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/File/BufferedOutputStream&amp;diff=5359&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:27Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  Append string to a text file ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.BufferedOutputStream;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import java.io.PrintStream;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] argv) {&lt;br /&gt;
    append(new File(&amp;quot;c:\\a.txt&amp;quot;), &amp;quot;value&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public static void append(File aFile, String content) {&lt;br /&gt;
    try {&lt;br /&gt;
      PrintStream p = new PrintStream(new BufferedOutputStream(new FileOutputStream(aFile, true)));&lt;br /&gt;
      p.println(content);&lt;br /&gt;
      p.close();&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      e.printStackTrace();&lt;br /&gt;
      System.err.println(aFile);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  BufferedOutputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;You should always wrap your OutputStream with a BufferedOutputStream for better performance. &lt;br /&gt;
The BufferedOutputStream class has two constructors that accept an OutputStream.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public BufferedOutputStream (OutputStream out)&lt;br /&gt;
public BufferedOutputStream (OutputStream out, int bufferSize)&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Create DataInputStream out of BufferedInputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.BufferedInputStream;&lt;br /&gt;
import java.io.DataInputStream;&lt;br /&gt;
import java.io.EOFException;&lt;br /&gt;
import java.io.FileInputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
public class PrimeReader {&lt;br /&gt;
  public static void main(String[] arguments) {&lt;br /&gt;
    try {&lt;br /&gt;
      FileInputStream file = new FileInputStream(&amp;quot;400primes.dat&amp;quot;);&lt;br /&gt;
      BufferedInputStream buff = new BufferedInputStream(file);&lt;br /&gt;
      DataInputStream data = new DataInputStream(buff);&lt;br /&gt;
      try {&lt;br /&gt;
        while (true) {&lt;br /&gt;
          int in = data.readInt();&lt;br /&gt;
          System.out.print(in + &amp;quot; &amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
      } catch (EOFException eof) {&lt;br /&gt;
        buff.close();&lt;br /&gt;
      }&lt;br /&gt;
    } catch (IOException e) {&lt;br /&gt;
      System.out.println(&amp;quot;Error - &amp;quot; + e.toString());&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Create DataOutputStream out of BufferedOutputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.BufferedOutputStream;&lt;br /&gt;
import java.io.DataOutputStream;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
public class PrimeWriter {&lt;br /&gt;
  public static void main(String[] arguments) {&lt;br /&gt;
    int[] primes = new int[400];&lt;br /&gt;
    int numPrimes = 0;&lt;br /&gt;
    int candidate = 2;&lt;br /&gt;
    while (numPrimes &amp;lt; 400) {&lt;br /&gt;
      primes[numPrimes] = candidate;&lt;br /&gt;
      numPrimes++;&lt;br /&gt;
      candidate++;&lt;br /&gt;
    }&lt;br /&gt;
    try {&lt;br /&gt;
      FileOutputStream file = new FileOutputStream(&amp;quot;p.dat&amp;quot;);&lt;br /&gt;
      BufferedOutputStream buff = new BufferedOutputStream(file);&lt;br /&gt;
      DataOutputStream data = new DataOutputStream(buff);&lt;br /&gt;
      for (int i = 0; i &amp;lt; 400; i++)&lt;br /&gt;
        data.writeInt(primes[i]);&lt;br /&gt;
      data.close();&lt;br /&gt;
    } catch (IOException e) {&lt;br /&gt;
      System.out.println(&amp;quot;Error - &amp;quot; + e.toString());&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Write byte array to file using BufferedOutputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.BufferedOutputStream;&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    FileOutputStream fos = new FileOutputStream(new File(&amp;quot;C:/Demo&amp;quot;));&lt;br /&gt;
    BufferedOutputStream bos = new BufferedOutputStream(fos);&lt;br /&gt;
    bos.write(&amp;quot;this is a test&amp;quot;.getBytes());&lt;br /&gt;
    bos.flush();&lt;br /&gt;
    bos.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Write byte to file using BufferedOutputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.BufferedOutputStream;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    FileOutputStream fos = new FileOutputStream(&amp;quot;C:/Demo.txt&amp;quot;);&lt;br /&gt;
    BufferedOutputStream bos = new BufferedOutputStream(fos);&lt;br /&gt;
    byte b = 66;&lt;br /&gt;
    // write a character represented by ascii 66 i.e. &amp;quot;B&amp;quot;&lt;br /&gt;
    bos.write(b);&lt;br /&gt;
    bos.flush();&lt;br /&gt;
    bos.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Write to file using BufferedOutputStream ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.BufferedOutputStream;&lt;br /&gt;
import java.io.FileOutputStream;&lt;br /&gt;
public class Main {&lt;br /&gt;
  public static void main(String[] args) throws Exception {&lt;br /&gt;
    BufferedOutputStream bufferedOutput = new BufferedOutputStream(new FileOutputStream(&lt;br /&gt;
        &amp;quot;yourFile.txt&amp;quot;));&lt;br /&gt;
    bufferedOutput.write(&amp;quot;Line one&amp;quot;.getBytes());&lt;br /&gt;
    bufferedOutput.write(&amp;quot;\n&amp;quot;.getBytes());&lt;br /&gt;
    bufferedOutput.write(65);&lt;br /&gt;
    bufferedOutput.close();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>