IT. Expert System.

Java Enterprise Edition (EE)

FileDataSource


javax.activation
Class FileDataSource

java.lang.Object
  javax.activation.FileDataSource
All Implemented Interfaces:
DataSource
public class FileDataSource
extends java.lang.Object
implements DataSource

The FileDataSource class implements a simple DataSource object that encapsulates a file. It provides data typing services via a FileTypeMap object.

FileDataSource Typing Semantics

The FileDataSource class delegates data typing of files to an object subclassed from the FileTypeMap class. The setFileTypeMap method can be used to explicitly set the FileTypeMap for an instance of FileDataSource. If no FileTypeMap is set, the FileDataSource will call the FileTypeMap's getDefaultFileTypeMap method to get the System's default FileTypeMap.

See Also:
DataSource, FileTypeMap, MimetypesFileTypeMap

Constructor Summary
FileDataSource(java.io.File file)
          Creates a FileDataSource from a File object.
FileDataSource(java.lang.String name)
          Creates a FileDataSource from the specified path name.
 
Method Summary
 java.lang.String getContentType()
          This method returns the MIME type of the data in the form of a string.
 java.io.File getFile()
          Return the File object that corresponds to this FileDataSource.
 java.io.InputStream getInputStream()
          This method will return an InputStream representing the the data and will throw an IOException if it can not do so.
 java.lang.String getName()
          Return the name of this object.
 java.io.OutputStream getOutputStream()
          This method will return an OutputStream representing the the data and will throw an IOException if it can not do so.
 void setFileTypeMap(FileTypeMap map)
          Set the FileTypeMap to use with this FileDataSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileDataSource

public FileDataSource(java.io.File file)
Creates a FileDataSource from a File object. Note: The file will not actually be opened until a method is called that requires the file to be opened.

Parameters:
file - the file

FileDataSource

public FileDataSource(java.lang.String name)
Creates a FileDataSource from the specified path name. Note: The file will not actually be opened until a method is called that requires the file to be opened.

Parameters:
name - the system-dependent file name.
Method Detail

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
This method will return an InputStream representing the the data and will throw an IOException if it can not do so. This method will return a new instance of InputStream with each invocation.

Specified by:
getInputStream in interface DataSource
Returns:
an InputStream
Throws:
java.io.IOException

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
This method will return an OutputStream representing the the data and will throw an IOException if it can not do so. This method will return a new instance of OutputStream with each invocation.

Specified by:
getOutputStream in interface DataSource
Returns:
an OutputStream
Throws:
java.io.IOException

getContentType

public java.lang.String getContentType()
This method returns the MIME type of the data in the form of a string. This method uses the currently installed FileTypeMap. If there is no FileTypeMap explictly set, the FileDataSource will call the getDefaultFileTypeMap method on FileTypeMap to acquire a default FileTypeMap. Note: By default, the FileTypeMap used will be a MimetypesFileTypeMap.

Specified by:
getContentType in interface DataSource
Returns:
the MIME Type
See Also:
FileTypeMap.getDefaultFileTypeMap()

getName

public java.lang.String getName()
Return the name of this object. The FileDataSource will return the file name of the object.

Specified by:
getName in interface DataSource
Returns:
the name of the object.
See Also:
DataSource

getFile

public java.io.File getFile()
Return the File object that corresponds to this FileDataSource.

Returns:
the File object for the file represented by this object.

setFileTypeMap

public void setFileTypeMap(FileTypeMap map)
Set the FileTypeMap to use with this FileDataSource

Parameters:
map - The FileTypeMap for this object.


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 1774 / . Delta: 0.01989 с