net.yura.mobile.io
Class NativeUtil

java.lang.Object
  extended by net.yura.mobile.io.NativeUtil

public class NativeUtil
extends Object


Field Summary
static String[][] EXTS_FILENAME
           
static long RECENT_PICTURE_TIME_INTERVAL
           
static String ROOT_PREX
           
static int TYPE_ALL
           
static int TYPE_AUDIO
           
static int TYPE_FOLDER
           
static int TYPE_OTHER
           
static int TYPE_PICTURE
           
static int TYPE_VIDEO
           
 
Constructor Summary
NativeUtil()
           
 
Method Summary
static void close(Object fc)
           
static void copyFile(String source, String destination)
          Copy a file through jsr-75
static boolean copyFile(String attachmentName, String srcFullName, String desFullPath)
          copy file to other dir sometimes Attachment.fileName did not equal local file name
static void deleteFile(String path)
          delete file or folder
static String extractName(String fullName)
          get file name from full path ex: c:/a/b/c.exe =>c.exe
static String extractPath(String fullName)
          get path from full path ex c:/a/b/c.exe => c:/a/b/
static Enumeration getDirectoryFiles(String dir)
          Returns the list of all files and directories available in a directory.
static int getFileSize(String fileName)
          open file and get file size
static int getFileType(String fname)
           
static javax.microedition.lcdui.Image getImageFromFile(String filename)
          return null if not enough mem to load image
static InputStream getInputStreamFromFileConnector(String fileName)
           
static long getLastModified(String fileName)
          Returns the date/time of which a file is last modified.
static javax.microedition.io.file.FileConnection getReadFileConnection(String fullName)
           
static javax.microedition.lcdui.Image getThumbnailFromFile(String fileName)
          will return null if no thumb found
static javax.microedition.io.file.FileConnection getWriteFileConnection(String fullName)
           
static boolean isFileType(String fname, int filetype)
           
static Vector listFiles(String dir, int filter, boolean recent)
           
static boolean localFileExists(String filePath)
          Check if the file specified in the path exists on the local filesystem.
static boolean mkDir(String dirName)
          mkdir in native
static byte[] readFile(String fileName, long startPos, int length)
          read file from native
static String writeFile(String fullname, boolean append, boolean deleteExisting, int fileStartPos, byte[] data, int dataStartPos, int dataLength)
          Write the data specified in a array out to the native filesystem.
static String writeFile(String fullname, boolean append, int fileStartPos, byte[] data, int dataStartPos, int dataLength)
          Write the data specified in a array out to the native filesystem.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXTS_FILENAME

public static final String[][] EXTS_FILENAME

RECENT_PICTURE_TIME_INTERVAL

public static final long RECENT_PICTURE_TIME_INTERVAL
See Also:
Constant Field Values

ROOT_PREX

public static final String ROOT_PREX
See Also:
Constant Field Values

TYPE_ALL

public static final int TYPE_ALL
See Also:
Constant Field Values

TYPE_AUDIO

public static final int TYPE_AUDIO
See Also:
Constant Field Values

TYPE_FOLDER

public static final int TYPE_FOLDER
See Also:
Constant Field Values

TYPE_OTHER

public static final int TYPE_OTHER
See Also:
Constant Field Values

TYPE_PICTURE

public static final int TYPE_PICTURE
See Also:
Constant Field Values

TYPE_VIDEO

public static final int TYPE_VIDEO
See Also:
Constant Field Values
Constructor Detail

NativeUtil

public NativeUtil()
Method Detail

close

public static void close(Object fc)

copyFile

public static void copyFile(String source,
                            String destination)
Copy a file through jsr-75

Parameters:
source - the path to the source file
destination - the path to the destination file

copyFile

public static boolean copyFile(String attachmentName,
                               String srcFullName,
                               String desFullPath)
copy file to other dir sometimes Attachment.fileName did not equal local file name

Parameters:
srcfileName - original filename
srcFullPath - src path
desFullPath - target dir name
Returns:
if success return true;

deleteFile

public static void deleteFile(String path)
delete file or folder

Parameters:
path - full path string

extractName

public static String extractName(String fullName)
get file name from full path ex: c:/a/b/c.exe =>c.exe

Parameters:
fullName - String
Returns:
String

extractPath

public static String extractPath(String fullName)
get path from full path ex c:/a/b/c.exe => c:/a/b/

Parameters:
fullName - String
Returns:
String

getDirectoryFiles

public static Enumeration getDirectoryFiles(String dir)
Returns the list of all files and directories available in a directory.

Parameters:
dir - The path to the directory we will look into.
Returns:
A String Enumeration of all the available files and directories inside dir.

getFileSize

public static int getFileSize(String fileName)
open file and get file size

Parameters:
fileName - String
Returns:
int ,file size

getFileType

public static int getFileType(String fname)

getImageFromFile

public static javax.microedition.lcdui.Image getImageFromFile(String filename)
return null if not enough mem to load image


getInputStreamFromFileConnector

public static InputStream getInputStreamFromFileConnector(String fileName)

getLastModified

public static long getLastModified(String fileName)
Returns the date/time of which a file is last modified.

Parameters:
fileName - File name icluding full path to the file
Returns:
Last modified time of the file in long format

getReadFileConnection

public static javax.microedition.io.file.FileConnection getReadFileConnection(String fullName)
                                                                       throws Exception
Throws:
Exception

getThumbnailFromFile

public static javax.microedition.lcdui.Image getThumbnailFromFile(String fileName)
will return null if no thumb found


getWriteFileConnection

public static javax.microedition.io.file.FileConnection getWriteFileConnection(String fullName)
                                                                        throws Exception
Throws:
Exception

isFileType

public static boolean isFileType(String fname,
                                 int filetype)

listFiles

public static Vector listFiles(String dir,
                               int filter,
                               boolean recent)

localFileExists

public static boolean localFileExists(String filePath)
Check if the file specified in the path exists on the local filesystem.

Parameters:
filePath - full file name
Returns:
return boolean, true if file exists, false if it does not

mkDir

public static boolean mkDir(String dirName)
mkdir in native

Parameters:
dirName - dir name
Returns:
if success return true

readFile

public static byte[] readFile(String fileName,
                              long startPos,
                              int length)
read file from native

Parameters:
fileName - file name
startPos - start position
length - read length, if -1, read all
Returns:
byte data[]

writeFile

public static String writeFile(String fullname,
                               boolean append,
                               boolean deleteExisting,
                               int fileStartPos,
                               byte[] data,
                               int dataStartPos,
                               int dataLength)
Write the data specified in a array out to the native filesystem.

Parameters:
fileName - full file name
append - indicates whether to append or create a new file
deleteExisting - indicates whether to delete the existing file if there is one
fileStartPos - start position of file
data - byte[]
dataStartPos - start position of byte[]
dataLength - write length
Returns:
return file name new created or elder, if null, means write failed

writeFile

public static String writeFile(String fullname,
                               boolean append,
                               int fileStartPos,
                               byte[] data,
                               int dataStartPos,
                               int dataLength)
Write the data specified in a array out to the native filesystem.

Parameters:
fileName - full file name
append - indicates whether to append or create a new file
fileStartPos - start position of file
data - byte[]
dataStartPos - start position of byte[]
dataLength - write length
Returns:
return file name new created or elder, if null, means write failed