{"id":226559,"date":"2014-06-17T21:21:04","date_gmt":"2014-06-17T17:21:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=226559"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=226559","title":{"rendered":"<span class=\"post_title\">\u041b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u043d\u044b\u0435 \u043f\u043e \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0432 Java: Parallel Copy<\/span>"},"content":{"rendered":"<div class=\"content html_format\">     \t\u0425\u043e\u0440\u043e\u0448\u0438\u0435 \u043b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u043d\u044b\u0435 \u043f\u043e \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u043e\u0441\u0442\u044b\u0435, \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435, \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0432 \u043d\u0430\u0440\u043e\u0434\u043d\u043e\u043c \u0445\u043e\u0437\u044f\u0439\u0441\u0442\u0432\u0435) \u2014 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0440\u0435\u0434\u043a\u043e\u0441\u0442\u044c. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0412\u0430\u043c \u043e\u0434\u043d\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0438 \u0447\u0435\u0442\u044b\u0440\u0435 \u043b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u043e\u0439 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 Java.<\/p>\n<h4>\u0423\u0441\u043b\u043e\u0432\u0438\u044f<\/h4>\n<p>  \u042d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <b>\u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u044c\u0449\u0438\u043a\u0430<\/b> \u0438\u0437 InputStream \u0432 OutputStream. \u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043f\u043e\u0442\u043e\u043a\u0435 \u0432\u044b\u0437\u0432\u0430\u0432\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434 copy(&#8230;)  <\/p>\n<pre><code class=\"java\">import java.io.IOException; import java.io.InputStream; import java.io.OutputStream;  public class CopyUtil {     public static void copy(InputStream src, OutputStream dst)throws IOException{         try (InputStream src0 = src; OutputStream dst0 = dst) {             int b;             while ((b = src.read()) != -1) {                 dst.write(b);             }         }     } } <\/code><\/pre>\n<p>  <a name=\"habracut\"><\/a><br \/>  \u042d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <b>\u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u044c\u0449\u0438\u043a\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438<\/b> \u0438\u0437 InputStream \u0432 OutputStream. \u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043f\u043e\u0442\u043e\u043a\u0435 \u0432\u044b\u0437\u0432\u0430\u0432\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434 copy(&#8230;)  <\/p>\n<pre><code class=\"java\">import java.io.IOException; import java.io.InputStream; import java.io.OutputStream;  public class CopyUtil {     public static void copy(InputStream src, OutputStream dst)throws IOException{         byte[] buff = new byte[128];         try (InputStream src0 = src; OutputStream dst0 = dst) {             int count;             while ((count = src.read(buff)) != -1) {                 dst.write(buff, 0, count);             }         }     } } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <b>\u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u044c\u0449\u0438\u043a\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438<\/b> \u0438\u0437 InputStream \u0432 OutputStream. \u041c\u044b \u0437\u0430\u0432\u043e\u0434\u0438\u043c \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u043d\u043e\u0432\u043e\u043c\u0443 \u043f\u043e\u0442\u043e\u043a\u0443 \u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0438\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0439 \u043e\u0447\u0435\u0440\u0435\u0434\u044c\u044e \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u043a \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044e  <\/p>\n<pre><code class=\"java\">import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.atomic.AtomicReference;  public class CopyUtil {     public static void copy(final InputStream src, final OutputStream dst) throws IOException {         \/\/ reader-to-writer byte[]-channel         final BlockingQueue&lt;byte[]&gt; buffer = new ArrayBlockingQueue&lt;&gt;(64);         \/\/ exception-channel from reader\/writer threads?         final AtomicReference&lt;Throwable&gt; ex = new AtomicReference&lt;&gt;();         final ThreadGroup group = new ThreadGroup(&quot;read-write&quot;) {             public void uncaughtException(Thread t, Throwable e) {ex.set(e);}         };         \/\/ reader from 'src'         Thread reader = new Thread(group, () -&gt; {             try (InputStream src0 = src) {              \/\/ 'src0' for auto-closing                 while (true) {                     byte[] data = new byte[128];        \/\/ new data buffer                     int count = src.read(data, 1, 127); \/\/ read up to 127 bytes                     data[0] = (byte) count;             \/\/ 0-byte is length-field                     buffer.put(data);                   \/\/ send to writer                     if (count == -1) {break;}           \/\/ src empty                 }             } catch (Exception e) {group.interrupt();}  \/\/ interrupt writer         });         reader.start();         \/\/ writer to 'dst'         Thread writer = new Thread(group, () -&gt; {             try (OutputStream dst0 = dst) {      \/\/ 'dst0' for auto-closing                 while (true) {                     byte[] data = buffer.take(); \/\/ get new data from reader                     if (data[0] == -1) {break;}  \/\/ its last data                     dst.write(data, 1, data[0]); \/\/                  }             } catch (Exception e) {group.interrupt();}  \/\/ interrupt writer         });         writer.start();         \/\/ wait to complete read\/write operations         try {             reader.join(); \/\/ wait for reader             writer.join(); \/\/ wait for writer         } catch (InterruptedException e) {throw new IOException(e);}         if (ex.get() != null) {throw new IOException(ex.get());}     } } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0442\u0435\u0441\u0442  <\/p>\n<pre><code class=\"java\">import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Arrays; import java.util.Random;  public class Test {     public static void main(String[] args) throws IOException {         Random rnd = new Random(0);         byte[] testData = new byte[64 * 1024];         rnd.nextBytes(testData);         ByteArrayOutputStream dst = new ByteArrayOutputStream();         CopyUtil.copy(new ByteArrayInputStream(testData), dst);         if (!Arrays.equals(testData, dst.toByteArray())) {             throw new AssertionError(&quot;Lab decision wrong!&quot;);         } else {             System.out.println(&quot;OK!&quot;);         }     } } <\/code><\/pre>\n<h4>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 #1<\/h4>\n<p>  \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u0434\u0432\u0443\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u043c\u044b \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0434\u0432\u0430 \u043f\u043e\u0442\u043e\u043a\u0430 \u2014 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438. \u041f\u0435\u0440\u0435\u043f\u0438\u0448\u0438\u0442\u0435 \u043a\u043e\u0434, \u0447\u0442\u043e \u0431\u044b \u0447\u0442\u0435\u043d\u0438\u0435 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u043b\u043e\u0441\u044c \u0432 \u043d\u043e\u0432\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435, \u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u043f\u043e\u0442\u043e\u043a\u043e\u043c, \u0432\u044b\u0437\u0432\u0430\u0432\u0448\u0438\u043c copy(&#8230;). \u041a\u0441\u0442\u0430\u0442\u0438, \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u043f\u0430\u0440\u044b join-\u043e\u0432, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0442\u043e\u043a \u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0435\u043c \u043a\u043e\u043d\u0446\u0435 \u0431\u0443\u0444\u0435\u0440\u0430 \u0437\u043d\u0430\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<h4>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 #2<\/h4>\n<p>  \u0412 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u043c \u0434\u0432\u0443\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0435 byte[]-\u0431\u0443\u0444\u0435\u0440\u0430, \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0438\u0445 \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044e, \u0430 \u0442\u043e\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430 \u0441\u044a\u0435\u0434\u0435\u043d\u0438\u0435 GC. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0443\u0441\u0442\u044b\u0445 \u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u043e\u0442 \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044f \u043a \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044e.<\/p>\n<h4>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 #3<\/h4>\n<p>  \u0412\u043e \u0432\u0441\u0435\u0445 \u0442\u0440\u0435\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u043a\u043e\u0434\u0430 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u2014 \u043e\u0434\u043d\u043e\u043c\u0443 \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044e. \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0439\u0442\u0435 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u2014 \u043c\u043d\u043e\u0433\u0438\u043c \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044f\u043c. \u0412\u0441\u0435 \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0427\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u0438 \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432 \u0441\u0432\u043e\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435. \u041d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043f\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044f \u2014 \u043f\u0443\u0441\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u0438 \u0447\u0438\u0442\u0430\u044e\u0442 \u0438\u0437 \u043e\u0434\u043d\u0438\u0445 \u043d\u0430 \u0432\u0441\u0435\u0445 \u0431\u0443\u0444\u0435\u0440\u043e\u0432, \u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u044d\u0442\u0438 \u0431\u0443\u0444\u0435\u0440\u0430 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u0447\u0435\u0440\u0435\u0434\u044f\u0445 (\u043e\u0442 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044e \u0442\u044f\u043d\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u044c).  <\/p>\n<pre><code class=\"java\">import java.io.IOException; import java.io.InputStream; import java.io.OutputStream;  public class CopyUtil {     public static void copy(InputStream src, OutputStream ... dst) throws IOException {         \/\/ some code     } } <\/code><\/pre>\n<h4>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 #4<\/h4>\n<p>  \u0421\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 #3 \u043d\u043e \u043e\u0431\u0440\u0430\u0437\u0443\u0439\u0442\u0435 \u043d\u0435 \u0442\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u044e &#8216;\u0437\u0432\u0435\u0437\u0434\u0430&#8217;, \u0433\u0434\u0435 \u0432 \u0446\u0435\u043d\u0442\u0440\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u0438 \u043e\u0442 \u043d\u0435\u0433\u043e \u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u043b\u0443\u0447\u0438 \u043a \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044f\u043c, \u0430 \u0442\u043e\u043f\u043e\u043b\u043e\u0433\u0438\u044e &#8216;\u043a\u043e\u043b\u044c\u0446\u043e&#8217;. \u0412 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u0438 \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u0438 \u0432\u044b\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043a\u0440\u0443\u0433 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u0431\u0443\u0444\u0435\u0440 \u043f\u043e \u043a\u0440\u0443\u0433\u0443. \u0427\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u2014 \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044e, \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044c \u2014 \u0432\u0442\u043e\u0440\u043e\u043c\u0443,\u2026 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044c \u2014 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044e. \u0418 \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u0443\u0444\u0435\u0440 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e.<\/p>\n<h4>\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u044b<\/h4>\n<p>  \u042f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 <a href=\"http:\/\/GolovachCourses.com\">\u043a\u0443\u0440\u0441\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e Java Core (online-\u043a\u0443\u0440\u0441)<\/a>.<br \/>  email: GolovachCourses@gmail.com<br \/>  skype: GolovachCourses      \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/company\/golovachcourses\/blog\/226559\/\"> http:\/\/habrahabr.ru\/company\/golovachcourses\/blog\/226559\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">     \t\u0425\u043e\u0440\u043e\u0448\u0438\u0435 \u043b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u043d\u044b\u0435 \u043f\u043e \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 (\u043f\u0440\u043e\u0441\u0442\u044b\u0435, \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435, \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0432 \u043d\u0430\u0440\u043e\u0434\u043d\u043e\u043c \u0445\u043e\u0437\u044f\u0439\u0441\u0442\u0432\u0435) \u2014 \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0440\u0435\u0434\u043a\u043e\u0441\u0442\u044c. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0412\u0430\u043c \u043e\u0434\u043d\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0438 \u0447\u0435\u0442\u044b\u0440\u0435 \u043b\u0430\u0431\u043e\u0440\u0430\u0442\u043e\u0440\u043d\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u043e\u0439 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 Java.<\/p>\n<h4>\u0423\u0441\u043b\u043e\u0432\u0438\u044f<\/h4>\n<p>  \u042d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <b>\u043e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u044c\u0449\u0438\u043a\u0430<\/b> \u0438\u0437 InputStream \u0432 OutputStream. \u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043f\u043e\u0442\u043e\u043a\u0435 \u0432\u044b\u0437\u0432\u0430\u0432\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434 copy(&#8230;)  <\/p>\n<pre><code class=\"java\">import java.io.IOException; import java.io.InputStream; import java.io.OutputStream;  public class CopyUtil {     public static void copy(InputStream src, OutputStream dst)throws IOException{         try (InputStream src0 = src; OutputStream dst0 = dst) {             int b;             while ((b = src.read()) != -1) {                 dst.write(b);             }         }     } } <\/code><\/pre>\n<p>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-226559","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/226559","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=226559"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/226559\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=226559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=226559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=226559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}