src/share/jaxws_classes/com/sun/xml/internal/ws/encoding/DataSourceStreamingDataHandler.java

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
equal deleted inserted replaced
366:8c0b6bccfe47 368:0989ad8c0860
1 /* 1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2012, 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
23 * questions. 23 * questions.
24 */ 24 */
25 25
26 package com.sun.xml.internal.ws.encoding; 26 package com.sun.xml.internal.ws.encoding;
27 27
28 import com.sun.xml.internal.org.jvnet.mimepull.MIMEPart;
29
30 import javax.activation.DataSource; 28 import javax.activation.DataSource;
31 import java.io.*; 29 import java.io.*;
32 30
33 import com.sun.xml.internal.ws.developer.StreamingDataHandler; 31 import com.sun.xml.internal.ws.developer.StreamingDataHandler;
34 32
39 37
40 public DataSourceStreamingDataHandler(DataSource ds) { 38 public DataSourceStreamingDataHandler(DataSource ds) {
41 super(ds); 39 super(ds);
42 } 40 }
43 41
42 @Override
44 public InputStream readOnce() throws IOException { 43 public InputStream readOnce() throws IOException {
45 return getInputStream(); 44 return getInputStream();
46 } 45 }
47 46
47 @Override
48 public void moveTo(File file) throws IOException { 48 public void moveTo(File file) throws IOException {
49 InputStream in = getInputStream(); 49 InputStream in = getInputStream();
50 OutputStream os = new FileOutputStream(file); 50 OutputStream os = new FileOutputStream(file);
51 byte[] temp = new byte[8192]; 51 try {
52 int len; 52 byte[] temp = new byte[8192];
53 while((len=in.read(temp)) != -1) { 53 int len;
54 os.write(temp, 0, len); 54 while((len=in.read(temp)) != -1) {
55 os.write(temp, 0, len);
56 }
57 in.close();
58 } finally {
59 if (os != null) {
60 os.close();
61 }
55 } 62 }
56 in.close();
57 os.close();
58 } 63 }
59 64
65 @Override
60 public void close() throws IOException { 66 public void close() throws IOException {
61 // nothing to do here 67 // nothing to do here
62 } 68 }
63 69
64 } 70 }

mercurial