blob: 64f46314b251e937206a26215d6ae727d6f6d947 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
package de.thedevstack.conversationsplus.utils;
import android.net.Uri;
import java.io.Closeable;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import de.thedevstack.conversationsplus.ConversationsPlusApplication;
/**
* Util to handle streams.
*/
public final class StreamUtil {
/**
* Opens an InputStream from Uri using the ContentResolver from application.
* @see android.content.ContentResolver#openInputStream(Uri)
* @param uri the uri to open
* @return the InputStream for given uri
* @throws FileNotFoundException if the provided URI could not be opened.
*/
public static InputStream openInputStreamFromContentResolver(Uri uri) throws FileNotFoundException {
return ConversationsPlusApplication.getInstance().getContentResolver().openInputStream(uri);
}
/**
* Closes a stream.
* IOException is silently ignored.
* @param stream the stream to close
*/
public static void close(Closeable stream) {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
}
}
}
/**
* Avoid instantiation of util class.
*/
private StreamUtil() {
// Static helper class
}
}
|