jdk/src/java.desktop/share/classes/com/sun/media/sound/ModelByteBuffer.java
changeset 40718 fe2adbe4d101
parent 40444 afabcfc2f3ef
equal deleted inserted replaced
40717:02500a642a8e 40718:fe2adbe4d101
     1 /*
     1 /*
     2  * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   198         this.len = len;
   198         this.len = len;
   199     }
   199     }
   200 
   200 
   201     public void writeTo(OutputStream out) throws IOException {
   201     public void writeTo(OutputStream out) throws IOException {
   202         if (root.file != null && root.buffer == null) {
   202         if (root.file != null && root.buffer == null) {
   203             InputStream is = getInputStream();
   203             try (InputStream is = getInputStream()) {
   204             byte[] buff = new byte[1024];
   204                 byte[] buff = new byte[1024];
   205             int ret;
   205                 int ret;
   206             while ((ret = is.read(buff)) != -1)
   206                 while ((ret = is.read(buff)) != -1) {
   207                 out.write(buff, 0, ret);
   207                     out.write(buff, 0, ret);
       
   208                 }
       
   209             }
   208         } else
   210         } else
   209             out.write(array(), (int) arrayOffset(), (int) capacity());
   211             out.write(array(), (int) arrayOffset(), (int) capacity());
   210     }
   212     }
   211 
   213 
   212     public InputStream getInputStream() {
   214     public InputStream getInputStream() {