|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jogamp.common.util.IOUtil
public class IOUtil
Method Summary | |
---|---|
static byte[] |
copyStream2ByteArray(InputStream stream)
Copy the specified input stream to a byte array, which is being returned. |
static ByteBuffer |
copyStream2ByteBuffer(InputStream stream)
Copy the specified input stream to a NIO ByteBuffer w/ native byte order, which is being returned. |
static int |
copyStream2Stream(InputStream in,
OutputStream out,
int totalNumBytes)
Copy the specified input stream to the specified output stream. |
static int |
copyURL2File(URL url,
File outFile)
Copy the specified input stream to the specified output file. |
static File |
createTempFile(String prefix,
String suffix)
Utilizing File.createTempFile(String, String, File) using
getTempRoot() as the directory parameter, ie. |
static String |
getBasename(String fname)
Returns the basename of the given fname w/o directory part |
static String |
getClassFileName(String clazzBinName)
|
static URL |
getClassURL(String clazzBinName,
ClassLoader cl)
|
static String |
getDirname(String fname)
Returns unified '/' dirname including the last '/' |
static String |
getFileSuffix(File file)
Returns the lowercase suffix of the given file name (the text after the last '.' in the file name). |
static String |
getFileSuffix(String filename)
Returns the lowercase suffix of the given file name (the text after the last '.' in the file name). |
static String |
getRelativeOf(File baseLocation,
String relativeFile)
Generates a path for the 'relativeFile' relative to the 'baseLocation'. |
static String |
getRelativeOf(URL baseLocation,
String relativeFile)
Generates a path for the 'relativeFile' relative to the 'baseLocation'. |
static URL |
getResource(Class<?> context,
String resourcePath)
Locating a resource using 'getResource(String path, ClassLoader cl)', with the context's package name-path plus the resourcePath (incl. |
static URL |
getResource(String resourcePath,
ClassLoader cl)
Locating a resource using the ClassLoader's facility if not null, the absolute URL and absolute file. |
static File |
getTempRoot()
On standard Java, the folder specified by java.io.tempdir
is returned. |
static boolean |
urlExists(URL url)
Returns true, if the URL exists and a connection could be opened. |
static boolean |
urlExists(URL url,
String dbgmsg)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static int copyURL2File(URL url, File outFile) throws IOException
IOException
public static int copyStream2Stream(InputStream in, OutputStream out, int totalNumBytes) throws IOException
in
- the sourceout
- the destinationtotalNumBytes
- informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown
IOException
public static byte[] copyStream2ByteArray(InputStream stream) throws IOException
IOException
public static ByteBuffer copyStream2ByteBuffer(InputStream stream) throws IOException
The implementation creates the ByteBuffer w/ copyStream2ByteArray(InputStream)
's returned byte array.
IOException
public static String getFileSuffix(File file)
file
- name of the file
NullPointerException
- if file is nullpublic static String getFileSuffix(String filename)
filename
- name of the file
NullPointerException
- if filename is nullpublic static String getClassFileName(String clazzBinName) throws IOException
IOException
public static URL getClassURL(String clazzBinName, ClassLoader cl) throws IOException
clazzBinName
- com.jogamp.common.util.cache.TempJarCachecl
-
IOException
public static String getBasename(String fname)
public static String getDirname(String fname)
public static URL getResource(Class<?> context, String resourcePath)
getResource(String, ClassLoader)
public static URL getResource(String resourcePath, ClassLoader cl)
ClassLoader.getResource(String)
,
ClassLoader.getSystemResource(String)
,
URL.URL(String)
,
File.File(String)
public static String getRelativeOf(File baseLocation, String relativeFile)
baseLocation
- denotes a directoryrelativeFile
- denotes a relative file to the baseLocationpublic static String getRelativeOf(URL baseLocation, String relativeFile)
baseLocation
- denotes a URL to a filerelativeFile
- denotes a relative file to the baseLocation's parent directorypublic static boolean urlExists(URL url)
public static boolean urlExists(URL url, String dbgmsg)
public static File createTempFile(String prefix, String suffix) throws IllegalArgumentException, IOException, SecurityException
File.createTempFile(String, String, File)
using
getTempRoot()
as the directory parameter, ie. location
of the root temp folder.
prefix
- suffix
-
IllegalArgumentException
IOException
SecurityException
File.createTempFile(String, String)
,
File.createTempFile(String, String, File)
,
getTempRoot()
public static File getTempRoot() throws SecurityException
java.io.tempdir
is returned.
On Android a temp
folder relative to the applications local folder
(see Context#getDir(String, int)
) is returned, if
the Android application/activity has registered it's Application Context
via StaticContext#setContext(Context)
.
This allows using the temp folder w/o the need for sdcard
access, which would be the java.io.tempdir
location on Android!
The purpose of this wrapper
is to allow unique code to be used
for both platforms w/o the need to handle extra permissions.
SecurityException
StaticContext#setContext(Context)
,
Context#getDir(String, int)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |