|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.golden.gamedev.util.FileUtil
public class FileUtil
Utility class provides functions for processing java.io.File
object, such as renaming file extension, reading and writing text file, etc.
Method Summary | |
---|---|
static String[] |
fileRead(File file)
Read an array of String from specified text file. |
static String[] |
fileRead(InputStream stream)
Read an array of String from specified stream. |
static String[] |
fileRead(URL url)
Read an array of String from specified URL. |
static boolean |
fileWrite(String[] text,
File file)
Writes an array of String to specified text file. |
static String |
getExtension(File f)
Returns extension of a file. |
static String |
getExtension(String st)
Returns extension of a string. |
static String |
getName(File f)
Returns name of a file without its extension. |
static String |
getName(String st)
Returns name of a string without its extension. |
static String |
getPath(File f)
Returns the path of specified file. |
static String |
getPath(String st)
Returns path of a string. |
static String |
getPathName(File f)
Returns path and name of a file without its extension. |
static String |
getPathName(String st)
Returns path and name of a string without its extension. |
static File |
setExtension(File f,
String ext)
Sets file extension. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean fileWrite(String[] text, File file)
text
- an array of string to write to the filefile
- a text file to be written the text to
public static String[] fileRead(File file)
file
- file to be read
public static String[] fileRead(InputStream stream)
stream
- input stream to be read
public static String[] fileRead(URL url)
url
- url to be read
public static File setExtension(File f, String ext)
For example:
Renaming "paul.dat"
to "paul.bin"
:
File f = new File("paul.dat"); File newFile = setExtension(f, "bin");
f
- file that it's extension to be renamedext
- the new file extension
public static String getExtension(File f)
"paul.dat"
will return "dat"
.
f
- file to get it's extension
public static String getExtension(String st)
"paul.dat"
will return "dat"
.
st
- string to get its extension
public static String getName(File f)
"paul.dat"
will return "paul"
.
f
- file to get it's name
public static String getName(String st)
"paul.dat"
will return "paul"
.
st
- string to get its name
public static String getPath(File f)
"c:\src\res\paul.dat"
will return
"c:\src\res\"
.
f
- file to get its path
public static String getPath(String st)
"c:\src\res\paul.dat"
will return
"c:\src\res\"
.
st
- string to get its path
public static String getPathName(File f)
"c:\src\res\paul.dat"
will return
"c:\src\res\paul"
.
f
- file to get its pathname
public static String getPathName(String st)
"c:\src\res\paul.dat"
will return
"c:\src\res\paul"
.
st
- string to get its pathname
|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |