1 /*
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.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
309 os.write(data, 0, bytes_read);
310 }
311 } finally {
312 is.close();
313 is = null;
314 }
315 } else { // for the Object case
316 DataContentHandler dch = getDataContentHandler();
317 dch.writeTo(object, objectMimeType, os);
318 }
319 }
320
321 /**
322 * Get an OutputStream for this DataHandler to allow overwriting
323 * the underlying data.
324 * If the DataHandler was created with a DataSource, the
325 * DataSource's {@code getOutputStream} method is called.
326 * Otherwise, {@code null} is returned.
327 *
328 * @return the OutputStream
329 *
330 * @see javax.activation.DataSource#getOutputStream
331 * @see javax.activation.URLDataSource
332 */
333 public OutputStream getOutputStream() throws IOException {
334 if (dataSource != null)
335 return dataSource.getOutputStream();
336 else
337 return null;
338 }
339
340 /**
341 * Return the DataFlavors in which this data is available. <p>
342 *
343 * Returns an array of DataFlavor objects indicating the flavors
344 * the data can be provided in. The array is usually ordered
345 * according to preference for providing the data, from most
346 * richly descriptive to least richly descriptive.<p>
347 *
348 * The DataHandler attempts to find a DataContentHandler that
|
1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
309 os.write(data, 0, bytes_read);
310 }
311 } finally {
312 is.close();
313 is = null;
314 }
315 } else { // for the Object case
316 DataContentHandler dch = getDataContentHandler();
317 dch.writeTo(object, objectMimeType, os);
318 }
319 }
320
321 /**
322 * Get an OutputStream for this DataHandler to allow overwriting
323 * the underlying data.
324 * If the DataHandler was created with a DataSource, the
325 * DataSource's {@code getOutputStream} method is called.
326 * Otherwise, {@code null} is returned.
327 *
328 * @return the OutputStream
329 * @exception IOException for failures creating the OutputStream
330 *
331 * @see javax.activation.DataSource#getOutputStream
332 * @see javax.activation.URLDataSource
333 */
334 public OutputStream getOutputStream() throws IOException {
335 if (dataSource != null)
336 return dataSource.getOutputStream();
337 else
338 return null;
339 }
340
341 /**
342 * Return the DataFlavors in which this data is available. <p>
343 *
344 * Returns an array of DataFlavor objects indicating the flavors
345 * the data can be provided in. The array is usually ordered
346 * according to preference for providing the data, from most
347 * richly descriptive to least richly descriptive.<p>
348 *
349 * The DataHandler attempts to find a DataContentHandler that
|