@ThreadSafe public class

AttachmentFileGetData

extends Object
implements AttachmentGetData
java.lang.Object
   ↳ com.atlassian.jira.issue.attachment.AttachmentFileGetData

Class Overview

Represents attachment data based on files system. The method getInputStream() can be called only once for each instance of this object. Method close() can be called multiple times. This class is thread safe, that means that getInputStream and close can be called from two threads, and when multiple threads try to call getInputStream only one will succeed and other will receive IllegalStateException

Summary

Public Constructors
AttachmentFileGetData(File file)
Public Methods
void close()
close the underlying input stream if this was and is open.
File getFile()
Size of file represented by this object, or 0 if the file does not exist or is directory
InputStream getInputStream()
Opens input stream for the file handled by this object.
long getSize()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.issue.attachment.AttachmentGetData

Public Constructors

public AttachmentFileGetData (File file)

Public Methods

public void close ()

close the underlying input stream if this was and is open. NOP in other cases.

public File getFile ()

Size of file represented by this object, or 0 if the file does not exist or is directory

Returns
  • file object represented by this object.

public InputStream getInputStream ()

Opens input stream for the file handled by this object. One can call this method only once for instance of this object. To close the stream use method close() of this class. Closing the stream directly in not an error in this case method close will be NOP.

Throws
if this method is called twice or close was called before this method.
RuntimeIOException if this object points to not existing file

public long getSize ()