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 |
60 public MIMEPartStreamingDataHandler(MIMEPart part) { |
60 public MIMEPartStreamingDataHandler(MIMEPart part) { |
61 super(new StreamingDataSource(part)); |
61 super(new StreamingDataSource(part)); |
62 ds = (StreamingDataSource)getDataSource(); |
62 ds = (StreamingDataSource)getDataSource(); |
63 } |
63 } |
64 |
64 |
|
65 @Override |
65 public InputStream readOnce() throws IOException { |
66 public InputStream readOnce() throws IOException { |
66 return ds.readOnce(); |
67 return ds.readOnce(); |
67 } |
68 } |
68 |
69 |
|
70 @Override |
69 public void moveTo(File file) throws IOException { |
71 public void moveTo(File file) throws IOException { |
70 ds.moveTo(file); |
72 ds.moveTo(file); |
71 } |
73 } |
72 |
74 |
|
75 @Override |
73 public void close() throws IOException { |
76 public void close() throws IOException { |
74 ds.close(); |
77 ds.close(); |
75 } |
78 } |
76 |
79 |
77 private static final class StreamingDataSource implements DataSource { |
80 private static final class StreamingDataSource implements DataSource { |
95 |
99 |
96 void moveTo(File file) throws IOException { |
100 void moveTo(File file) throws IOException { |
97 part.moveTo(file); |
101 part.moveTo(file); |
98 } |
102 } |
99 |
103 |
|
104 @Override |
100 public OutputStream getOutputStream() throws IOException { |
105 public OutputStream getOutputStream() throws IOException { |
101 return null; |
106 return null; |
102 } |
107 } |
103 |
108 |
|
109 @Override |
104 public String getContentType() { |
110 public String getContentType() { |
105 return part.getContentType(); |
111 return part.getContentType(); |
106 } |
112 } |
107 |
113 |
|
114 @Override |
108 public String getName() { |
115 public String getName() { |
109 return ""; |
116 return ""; |
110 } |
117 } |
111 |
118 |
112 public void close() throws IOException { |
119 public void close() throws IOException { |