GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
com.jogamp.common.util.IOUtil Class Reference
Collaboration diagram for com.jogamp.common.util.IOUtil:

Classes

class  ClassResources
 Helper compound associating a class instance and resource paths to be resolved at a later time. More...
 
class  StreamMonitor
 

Static Public Member Functions

static int copyURLConn2File (final URLConnection conn, final File outFile) throws IOException
 Copy the complete specified URL resource to the specified output file. More...
 
static int copyStream2File (final InputStream in, final File outFile) throws IOException
 Copy the complete specified input stream to the specified output file. More...
 
static int copyStream2Stream (final InputStream in, final OutputStream out) throws IOException
 Copy the complete specified input stream to the specified output stream. More...
 
static int copyStream2Stream (final int bufferSize, final InputStream in, final OutputStream out) throws IOException
 Copy the complete specified input stream to the specified output stream. More...
 
static StringBuilder appendCharStream (final StringBuilder sb, final Reader r) throws IOException
 
static byte[] copyStream2ByteArray (InputStream stream) throws IOException
 Copy the complete specified input stream to a byte array, which is being returned. More...
 
static ByteBuffer copyStream2ByteBuffer (final InputStream stream) throws IOException
 Copy the complete specified input stream to a NIO ByteBuffer w/ native byte order, which is being returned. More...
 
static ByteBuffer copyStream2ByteBuffer (InputStream stream, int initialCapacity) throws IOException
 Copy the complete specified input stream to a NIO ByteBuffer w/ native byte order, which is being returned. More...
 
static ByteBuffer copyStreamChunk2ByteBuffer (InputStream stream, int skipBytes, int byteCount) throws IOException
 Copy the specified input stream chunk to a NIO ByteBuffer w/ native byte order, which is being returned. More...
 
static String slashify (final String path, final boolean startWithSlash, final boolean endWithSlash) throws URISyntaxException
 
static String getFileSuffix (final File file)
 Returns the lowercase suffix of the given file name (the text after the last '. More...
 
static String getFileSuffix (final String filename)
 Returns the lowercase suffix of the given file name (the text after the last '. More...
 
static FileOutputStream getFileOutputStream (final File file, final boolean allowOverwrite) throws IOException
 
static String getClassFileName (final String clazzBinName)
 
static URL getClassURL (final String clazzBinName, final ClassLoader cl) throws IOException
 
static String getBasename (String fname) throws URISyntaxException
 Returns the basename of the given fname w/o directory part. More...
 
static String getDirname (String fname) throws URISyntaxException
 Returns unified '/' dirname including the last '/'. More...
 
static URLConnection getResource (final String resourcePath, final ClassLoader classLoader, final Class<?> relContext)
 Locating a resource using getResource(String, ClassLoader): More...
 
static URLConnection getResource (final String resourcePath, final ClassLoader cl)
 Locating a resource using the ClassLoader's facilities. More...
 
static String getRelativeOf (final File baseLocation, final String relativeFile) throws URISyntaxException
 Generates a path for the 'relativeFile' relative to the 'baseLocation'. More...
 
static String getParentOf (final String path) throws URISyntaxException
 
static String cleanPathString (String path) throws URISyntaxException
 
static String getUriFilePathOrASCII (final Uri uri)
 If uri is a file scheme implementation returns Uri#toFile(). More...
 
static URLConnection openURL (final URL url)
 Returns the connected URLConnection, or null if not url is not available. More...
 
static URLConnection openURL (final URL url, final String dbgmsg)
 Returns the connected URLConnection, or null if not url is not available. More...
 
static boolean testFile (final File file, final boolean shallBeDir, final boolean shallBeWritable)
 Test whether file exists and matches the given requirements. More...
 
static boolean testDirExec (final File dir) throws SecurityException
 Returns true if the given dir @endiliteral.
More...
 
static File testDir (final File dir, final boolean create, final boolean executable) throws SecurityException
 Returns the directory dir, which is processed and tested as described below. More...
 
static File getTempDir (final boolean executable) throws SecurityException, IOException
 Returns a platform independent writable directory for temporary files consisting of the platform's temp-root + tmpSubDir, e.g. More...
 
static File createTempFile (final String prefix, final String suffix, final boolean executable) throws IllegalArgumentException, IOException, SecurityException
 Utilizing File#createTempFile(String, String, File) using getTempDir(boolean) as the directory parameter, ie. More...
 
static void close (final Closeable stream, final boolean throwRuntimeException) throws RuntimeException
 
static IOException close (final Closeable stream, final IOException[] saveOneIfFree, final PrintStream dumpExcess)
 Helper to simplify closing Closeables. More...
 
static ArrayList< String > filesOf (final List< String > paths, final List< Pattern > excludes, final List< Pattern > includes)
 Retrieve the list of all filenames traversing through given paths. More...
 

Static Public Attributes

static final boolean DEBUG
 
static final String tmpSubDir = "jogamp"
 Subdirectory within platform's temporary root directory where all JogAmp related temp files are being stored: jogamp
More...
 
static final Pattern patternSpaceEnc = Pattern.compile("%20")
 

Detailed Description

Definition at line 69 of file IOUtil.java.

Member Function Documentation

◆ appendCharStream()

static StringBuilder com.jogamp.common.util.IOUtil.appendCharStream ( final StringBuilder  sb,
final Reader  r 
) throws IOException
static

Definition at line 250 of file IOUtil.java.

◆ cleanPathString()

static String com.jogamp.common.util.IOUtil.cleanPathString ( String  path) throws URISyntaxException
static
Parameters
pathassuming a slashified path, either denoting a file or directory, either relative or absolute.
Returns
clean path string where ./ and ../ is resolved, while keeping a starting ../ at the beginning of a relative path.
Exceptions
URISyntaxExceptionif path is empty or has no parent directory available while resolving ../

Definition at line 712 of file IOUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ close() [1/2]

static void com.jogamp.common.util.IOUtil.close ( final Closeable  stream,
final boolean  throwRuntimeException 
) throws RuntimeException
static

Definition at line 1405 of file IOUtil.java.

Here is the caller graph for this function:

◆ close() [2/2]

static IOException com.jogamp.common.util.IOUtil.close ( final Closeable  stream,
final IOException[]  saveOneIfFree,
final PrintStream  dumpExcess 
)
static

Helper to simplify closing Closeables.

Parameters
streamthe Closeable instance to close
saveOneIfFreecache for one IOException to store, if not already used (excess)
dumpExcessdump the excess IOException on this PrintStream
Returns
the excess IOException or null.

Definition at line 1428 of file IOUtil.java.

◆ copyStream2ByteArray()

static byte[] com.jogamp.common.util.IOUtil.copyStream2ByteArray ( InputStream  stream) throws IOException
static

Copy the complete specified input stream to a byte array, which is being returned.

Definition at line 262 of file IOUtil.java.

Here is the caller graph for this function:

◆ copyStream2ByteBuffer() [1/2]

static ByteBuffer com.jogamp.common.util.IOUtil.copyStream2ByteBuffer ( final InputStream  stream) throws IOException
static

Copy the complete specified input stream to a NIO ByteBuffer w/ native byte order, which is being returned.

Parameters
streaminput stream, which will be wrapped into a BufferedInputStream, if not already done.

Definition at line 297 of file IOUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyStream2ByteBuffer() [2/2]

static ByteBuffer com.jogamp.common.util.IOUtil.copyStream2ByteBuffer ( InputStream  stream,
int  initialCapacity 
) throws IOException
static

Copy the complete specified input stream to a NIO ByteBuffer w/ native byte order, which is being returned.

Parameters
streaminput stream, which will be wrapped into a BufferedInputStream, if not already done.
initialCapacityinitial buffer capacity in bytes, if < currently available bytes, initial buffer capacity is set to currently available bytes.

Definition at line 307 of file IOUtil.java.

Here is the call graph for this function:

◆ copyStream2File()

static int com.jogamp.common.util.IOUtil.copyStream2File ( final InputStream  in,
final File  outFile 
) throws IOException
static

Copy the complete specified input stream to the specified output file.

The total number of bytes written is returned.

Parameters
inthe source
outFilethe destination
Returns
Exceptions
IOException

Definition at line 204 of file IOUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyStream2Stream() [1/2]

static int com.jogamp.common.util.IOUtil.copyStream2Stream ( final InputStream  in,
final OutputStream  out 
) throws IOException
static

Copy the complete specified input stream to the specified output stream.

The total number of bytes written is returned.

Parameters
inthe source
outthe destination
Returns
Exceptions
IOException

Definition at line 222 of file IOUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyStream2Stream() [2/2]

static int com.jogamp.common.util.IOUtil.copyStream2Stream ( final int  bufferSize,
final InputStream  in,
final OutputStream  out 
) throws IOException
static

Copy the complete specified input stream to the specified output stream.

The total number of bytes written is returned.

Parameters
bufferSizethe intermediate buffer size, should be MachineDataInfo#pageSizeInBytes() for best performance.
inthe source
outthe destination
Returns
Exceptions
IOException

Definition at line 236 of file IOUtil.java.

◆ copyStreamChunk2ByteBuffer()

static ByteBuffer com.jogamp.common.util.IOUtil.copyStreamChunk2ByteBuffer ( InputStream  stream,
int  skipBytes,
int  byteCount 
) throws IOException
static

Copy the specified input stream chunk to a NIO ByteBuffer w/ native byte order, which is being returned.

Parameters
streaminput stream, which will be wrapped into a BufferedInputStream, if not already done.
skipBytesinitial bytes to skip from input stream.
byteCountbytes to copy starting after skipBytes.

Definition at line 347 of file IOUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyURLConn2File()

static int com.jogamp.common.util.IOUtil.copyURLConn2File ( final URLConnection  conn,
final File  outFile 
) throws IOException
static

Copy the complete specified URL resource to the specified output file.

The total number of bytes written is returned.

Parameters
connthe open URLConnection
outFilethe destination
Returns
Exceptions
IOException

Definition at line 182 of file IOUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createTempFile()

static File com.jogamp.common.util.IOUtil.createTempFile ( final String  prefix,
final String  suffix,
final boolean  executable 
) throws IllegalArgumentException, IOException, SecurityException
static

Utilizing File#createTempFile(String, String, File) using getTempDir(boolean) as the directory parameter, ie.

location of the root temp folder.

See also
File::createTempFile(String, String)
File::createTempFile(String, String, File)
getTempDir(boolean)
Parameters
prefix
suffix
executabletrue if the temporary root folder needs to hold executable files, otherwise false.
Returns
Exceptions
IllegalArgumentException
IOExceptionif no temporary directory could be determined or temp file could not be created
SecurityException

Definition at line 1399 of file IOUtil.java.

Here is the call graph for this function:

◆ filesOf()

static ArrayList< String > com.jogamp.common.util.IOUtil.filesOf ( final List< String >  paths,
final List< Pattern >  excludes,
final List< Pattern >  includes 
)
static

Retrieve the list of all filenames traversing through given paths.

Parameters
pathslist of paths to traverse through, containing directories and files
excludesoptional list of exclude Pattern. All matching files or directories will be omitted. Maybe be null or empty.
includesoptional list of explicit include Pattern. If given, only matching files will be returned, otherwise all occurring.
Returns
list of unsorted filenames within given paths

Definition at line 1452 of file IOUtil.java.

Here is the caller graph for this function:

◆ getBasename()

static String com.jogamp.common.util.IOUtil.getBasename ( String  fname) throws URISyntaxException
static

Returns the basename of the given fname w/o directory part.

Exceptions
URISyntaxExceptionif path is empty or has no parent directory available while resolving ../

Definition at line 486 of file IOUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getClassFileName()

static String com.jogamp.common.util.IOUtil.getClassFileName ( final String  clazzBinName)
static

Definition at line 463 of file IOUtil.java.

Here is the caller graph for this function:

◆ getClassURL()

static URL com.jogamp.common.util.IOUtil.getClassURL ( final String  clazzBinName,
final ClassLoader  cl 
) throws IOException
static
Parameters
clazzBinNamecom.jogamp.common.util.cache.TempJarCache
clClassLoader to locate the JarFile
Returns
jar:file:/usr/local/projects/JOGL/gluegen/build-x86_64/gluegen-rt.jar!/com/jogamp/common/util/cache/TempJarCache.class
Exceptions
IOExceptionif the jar file could not been found by the ClassLoader

Definition at line 474 of file IOUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDirname()

static String com.jogamp.common.util.IOUtil.getDirname ( String  fname) throws URISyntaxException
static

Returns unified '/' dirname including the last '/'.

Exceptions
URISyntaxExceptionif path is empty or has no parent directory available while resolving ../

Definition at line 499 of file IOUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFileOutputStream()

static FileOutputStream com.jogamp.common.util.IOUtil.getFileOutputStream ( final File  file,
final boolean  allowOverwrite 
) throws IOException
static

Definition at line 448 of file IOUtil.java.

◆ getFileSuffix() [1/2]

static String com.jogamp.common.util.IOUtil.getFileSuffix ( final File  file)
static

Returns the lowercase suffix of the given file name (the text after the last '.

' in the file name). Returns null if the file name has no suffix. Only operates on the given file name; performs no I/O operations.

Parameters
filename of the file
Returns
lowercase suffix of the file name
Exceptions
NullPointerExceptionif file is null

Definition at line 411 of file IOUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFileSuffix() [2/2]

static String com.jogamp.common.util.IOUtil.getFileSuffix ( final String  filename)
static

Returns the lowercase suffix of the given file name (the text after the last '.

' in the file name). Returns null if the file name has no suffix. Only operates on the given file name; performs no I/O operations.

Parameters
filenamename of the file
Returns
lowercase suffix of the file name
Exceptions
NullPointerExceptionif filename is null

Definition at line 425 of file IOUtil.java.

◆ getParentOf()

static String com.jogamp.common.util.IOUtil.getParentOf ( final String  path) throws URISyntaxException
static
Parameters
pathassuming a slashified path, either denotes a file or directory, either relative or absolute.
Returns
parent of path
Exceptions
URISyntaxExceptionif path is empty or has no parent directory available

Definition at line 670 of file IOUtil.java.

Here is the caller graph for this function:

◆ getRelativeOf()

static String com.jogamp.common.util.IOUtil.getRelativeOf ( final File  baseLocation,
final String  relativeFile 
) throws URISyntaxException
static

Generates a path for the 'relativeFile' relative to the 'baseLocation'.

Parameters
baseLocationdenotes a directory
relativeFiledenotes a relative file to the baseLocation
Exceptions
URISyntaxExceptionif path is empty or has no parent directory available while resolving ../

Definition at line 652 of file IOUtil.java.

Here is the call graph for this function:

◆ getResource() [1/2]

static URLConnection com.jogamp.common.util.IOUtil.getResource ( final String  resourcePath,
final ClassLoader  cl 
)
static

Locating a resource using the ClassLoader's facilities.

Returns the resolved and connected URLConnection or null if not found.

See also
ClassLoader::getResource(String)
ClassLoader::getSystemResource(String)
URL::URL(String)
File::File(String)

Definition at line 617 of file IOUtil.java.

Here is the call graph for this function:

◆ getResource() [2/2]

static URLConnection com.jogamp.common.util.IOUtil.getResource ( final String  resourcePath,
final ClassLoader  classLoader,
final Class<?>  relContext 
)
static

Locating a resource using getResource(String, ClassLoader):

  • relative: relContext's package name-path plus resourcePath via classLoader. This allows locations relative to JAR- and other URLs. The resourcePath may start with ../ to navigate to parent folder. This attempt is skipped if relContext is null.
  • absolute: resourcePath as is via classLoader.

Returns the resolved and open URLConnection or null if not found.

Parameters
resourcePaththe resource path to locate relative or absolute
classLoaderthe optional ClassLoader, recommended
relContextrelative context, i.e. position, of the resourcePath, to perform the relative lookup, if not null.
See also
getResource(String, ClassLoader)
ClassLoader::getResource(String)
ClassLoader::getSystemResource(String)

Definition at line 578 of file IOUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTempDir()

static File com.jogamp.common.util.IOUtil.getTempDir ( final boolean  executable) throws SecurityException, IOException
static

Returns a platform independent writable directory for temporary files consisting of the platform's temp-root + tmpSubDir, e.g.

/tmp/jogamp_0000/.

On standard Java the temp-root folder is specified by java.io.tempdir.

On Android the temp-root folder is 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.init(..). This allows using the temp folder w/o the need for sdcard access, which would be the java.io.tempdir location on Android!

In case temp-root is the users home folder, a dot is being prepended to tmpSubDir, i.e.: /home/user/.jogamp_0000/.

Parameters
executabletrue if the user intents to launch executables from the temporary directory, otherwise false.
Exceptions
IOExceptionif no temporary directory could be determined
SecurityExceptionif access to java.io.tmpdir is not allowed within the current security context
See also
PropertyAccess::getProperty(String, boolean)
Context::getDir(String, int)

Definition at line 1246 of file IOUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getUriFilePathOrASCII()

static String com.jogamp.common.util.IOUtil.getUriFilePathOrASCII ( final Uri  uri)
static

If uri is a file scheme implementation returns Uri#toFile().

File#getPath().

Otherwise it returns the URI#toASCIIString() encoded URI.

Definition at line 744 of file IOUtil.java.

Here is the call graph for this function:

◆ openURL() [1/2]

static URLConnection com.jogamp.common.util.IOUtil.openURL ( final URL  url)
static

Returns the connected URLConnection, or null if not url is not available.

Definition at line 755 of file IOUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openURL() [2/2]

static URLConnection com.jogamp.common.util.IOUtil.openURL ( final URL  url,
final String  dbgmsg 
)
static

Returns the connected URLConnection, or null if not url is not available.

Definition at line 762 of file IOUtil.java.

Here is the call graph for this function:

◆ slashify()

static String com.jogamp.common.util.IOUtil.slashify ( final String  path,
final boolean  startWithSlash,
final boolean  endWithSlash 
) throws URISyntaxException
static
Parameters
path
startWithSlash
endWithSlash
Returns
Exceptions
URISyntaxExceptionif path is empty or has no parent directory available while resolving ../

Definition at line 389 of file IOUtil.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ testDir()

static File com.jogamp.common.util.IOUtil.testDir ( final File  dir,
final boolean  create,
final boolean  executable 
) throws SecurityException
static

Returns the directory dir, which is processed and tested as described below.

  1. If create is true and the directory does not exist yet, it is created incl. all sub-directories.
  2. If dirName exists, but is not a directory, null is being returned.
  3. If the directory does not exist or is not writeable, null is being returned.
  4. If executable is true and files cannot be executed from the directory, null is being returned.
Parameters
dirthe directory to process
createtrue if the directory shall be created if not existing
executabletrue if the user intents to launch executables from the temporary directory, otherwise false.
Exceptions
SecurityExceptionif file creation and process execution is not allowed within the current security context

Definition at line 1167 of file IOUtil.java.

◆ testDirExec()

static boolean com.jogamp.common.util.IOUtil.testDirExec ( final File  dir) throws SecurityException
static

Returns true if the given dir @endiliteral.

  1. exists, and
  2. is a directory, and
  3. is writeable, and
  4. files can be executed from the directory
Exceptions
SecurityExceptionif file creation and process execution is not allowed within the current security context
Parameters
dir

Definition at line 1018 of file IOUtil.java.

Here is the call graph for this function:

◆ testFile()

static boolean com.jogamp.common.util.IOUtil.testFile ( final File  file,
final boolean  shallBeDir,
final boolean  shallBeWritable 
)
static

Test whether file exists and matches the given requirements.

Parameters
file
shallBeDir
shallBeWritable
Returns

Definition at line 918 of file IOUtil.java.

Here is the caller graph for this function:

Member Data Documentation

◆ DEBUG

final boolean com.jogamp.common.util.IOUtil.DEBUG
static

Definition at line 70 of file IOUtil.java.

◆ patternSpaceEnc

final Pattern com.jogamp.common.util.IOUtil.patternSpaceEnc = Pattern.compile("%20")
static

Definition at line 735 of file IOUtil.java.

◆ tmpSubDir

final String com.jogamp.common.util.IOUtil.tmpSubDir = "jogamp"
static

Subdirectory within platform's temporary root directory where all JogAmp related temp files are being stored: jogamp

Definition at line 132 of file IOUtil.java.


The documentation for this class was generated from the following file: