public class Utils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.logging.Logger |
logger |
private static int |
MAX_BASE_TEMP_FILENAME_LENGTH |
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static void |
copy(byte[] src,
byte[] dst,
int dstOffset)
Copies the bytes of
srd to dst at the
specified offset. |
static boolean |
copy(java.io.File fromFile,
java.io.File toFile)
Copy a File
|
static java.lang.String |
getBaseFilenameForTempFile(java.io.File file)
Get a base for temp file, this should be long enough so that it easy to work out later what file the temp file
was created for if it is left lying round, but not ridiculously long as this can cause problems with max filename
limits and is not very useful
|
static byte[] |
getDefaultBytes(java.lang.String s,
java.lang.String charSet)
Returns
String.getBytes() . |
static java.lang.String |
getExtension(java.io.File f) |
static int |
getIntBE(byte[] b,
int start,
int end) |
static int |
getIntBE(java.nio.ByteBuffer b,
int start,
int end) |
static int |
getIntLE(byte[] b) |
static int |
getIntLE(byte[] b,
int start,
int end) |
static long |
getLongBE(java.nio.ByteBuffer b,
int start,
int end) |
static long |
getLongLE(java.nio.ByteBuffer b,
int start,
int end) |
static java.lang.String |
getMinBaseFilenameAllowedForTempFile(java.io.File file) |
static short |
getShortBE(java.nio.ByteBuffer b,
int start,
int end) |
static byte[] |
getSizeBEInt16(short size)
Convert short to byte representation - Big Endian (as used by mp4)
|
static byte[] |
getSizeBEInt32(int size)
Convert int to byte representation - Big Endian (as used by mp4)
|
static byte[] |
getSizeLEInt32(int size)
Convert int to byte representation - Little Endian (as used by ogg vorbis)
|
static java.lang.String |
getString(byte[] b,
int offset,
int length,
java.lang.String encoding)
Create String starting from offset upto length using encoding
|
static java.lang.String |
getString(java.nio.ByteBuffer buffer,
int offset,
int length,
java.lang.String encoding)
Create String offset from position by offset upto length using encoding, and position of buffer
is moved to after position + offset + length
|
static byte[] |
getUTF8Bytes(java.lang.String s) |
static int |
read(java.nio.ByteBuffer b) |
static int |
readInt16(java.io.DataInput di)
Read a 16-bit big-endian signed integer
|
static java.lang.String |
readString(java.io.DataInput di,
int charsToRead)
Read a string of a specified number of ASCII bytes
|
static int |
readUBEInt16(java.nio.ByteBuffer b)
Read an unsigned big-endian 16-bit integer using an
nio ByteBuffer
|
static int |
readUBEInt24(java.nio.ByteBuffer b)
Read an unsigned big-endian 24-bit integer using an
nio ByteBuffer
|
static int |
readUBEInt32(java.nio.ByteBuffer b)
Read an unsigned big-endian 32-bit integer using an nio ByteBuffer
|
static int |
readUint16(java.io.DataInput di)
Read a 16-bit big-endian unsigned integer
|
static long |
readUint32(java.io.DataInput di)
Read a 32-bit big-endian unsigned integer using a DataInput.
|
static int |
readUint32AsInt(java.io.DataInput di)
Reads a 32-bit integer and returns it as a (signed) int.
|
static long |
readUInt64(java.nio.ByteBuffer b)
Read a 64-bit unsigned integer using an nio ByteBuffer
|
static int |
readUInt8(java.nio.ByteBuffer b)
Read an unsigned (endian-neutral) 8-bit integer using an
nio ByteBuffer
|
static boolean |
rename(java.io.File fromFile,
java.io.File toFile)
Rename file, and if normal rename fails, try copy and delete instead
|
public static java.util.logging.Logger logger
private static final int MAX_BASE_TEMP_FILENAME_LENGTH
public static void copy(byte[] src, byte[] dst, int dstOffset)
srd
to dst
at the
specified offset.src
- The byte to be copied.dst
- The array to copy todstOffset
- The start offset for the bytes to be copied.public static byte[] getDefaultBytes(java.lang.String s, java.lang.String charSet)
String.getBytes()
.s
- The String to call, decode bytes using the specfied charsetcharSet
- public static java.lang.String getExtension(java.io.File f)
public static long getLongLE(java.nio.ByteBuffer b, int start, int end)
public static long getLongBE(java.nio.ByteBuffer b, int start, int end)
public static int getIntLE(byte[] b)
public static int getIntLE(byte[] b, int start, int end)
public static int getIntBE(byte[] b, int start, int end)
public static int getIntBE(java.nio.ByteBuffer b, int start, int end)
public static short getShortBE(java.nio.ByteBuffer b, int start, int end)
public static byte[] getSizeBEInt32(int size)
size
- public static byte[] getSizeBEInt16(short size)
size
- number to convertpublic static byte[] getSizeLEInt32(int size)
size
- number to convertpublic static java.lang.String getString(byte[] b, int offset, int length, java.lang.String encoding)
b
- offset
- length
- encoding
- java.lang.RuntimeException
public static java.lang.String getString(java.nio.ByteBuffer buffer, int offset, int length, java.lang.String encoding)
buffer
- offset
- length
- encoding
- java.lang.RuntimeException
public static byte[] getUTF8Bytes(java.lang.String s) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingException
public static int readUint32AsInt(java.io.DataInput di) throws java.io.IOException
di
- The input sourcejava.io.IOException
public static long readUint32(java.io.DataInput di) throws java.io.IOException
java.io.IOException
public static int readUint16(java.io.DataInput di) throws java.io.IOException
java.io.IOException
public static int readInt16(java.io.DataInput di) throws java.io.IOException
java.io.IOException
public static java.lang.String readString(java.io.DataInput di, int charsToRead) throws java.io.IOException
java.io.IOException
public static long readUInt64(java.nio.ByteBuffer b)
public static int readUBEInt32(java.nio.ByteBuffer b)
public static int readUBEInt24(java.nio.ByteBuffer b)
public static int readUBEInt16(java.nio.ByteBuffer b)
public static int readUInt8(java.nio.ByteBuffer b)
public static int read(java.nio.ByteBuffer b)
public static java.lang.String getBaseFilenameForTempFile(java.io.File file)
file
- public static java.lang.String getMinBaseFilenameAllowedForTempFile(java.io.File file)
file
- public static boolean rename(java.io.File fromFile, java.io.File toFile)
fromFile
- toFile
- public static boolean copy(java.io.File fromFile, java.io.File toFile)
fromFile
- The existing FiletoFile
- The new Filetrue
if and only if the renaming succeeded;
false
otherwiseCopyright © 2005-2013 java.net. All Rights Reserved.