|
andyLib v0.9.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.andynaz.utils.UtilsIO
public class UtilsIO
Useful methods for an elementary file management.
Constructor Summary | |
---|---|
private |
UtilsIO()
|
Method Summary | |
---|---|
static void |
cp(File inFile,
File outFile)
Copy a file. |
static void |
cp(InputStream in,
OutputStream out)
Copy the content of an InputStream in an OutputStream . |
static int |
getUnsignedInt(byte b)
Convert a byte in an unsigned int. |
static boolean |
mv(File from,
File to)
Moves a file. |
static void |
print(InputStream in)
Write the content of the input stream on the System.out . |
static StringBuilder |
readFromFile(File file)
Reads the content of a text file. |
static boolean |
writeToFile(File file,
String text)
Writes a string in a text file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
private UtilsIO()
Method Detail |
---|
public static StringBuilder readFromFile(File file) throws FileNotFoundException, IOException
StringBuilder
for efficency.
file
- file to be read
FileNotFoundException
- if the file does not exist
IOException
- if I/O errors occourpublic static boolean writeToFile(File file, String text)
In case of error, the writing is interrupted and a log is produced on the standard output.
file
- file to be writtentext
- text to write
public static void cp(InputStream in, OutputStream out) throws IOException
InputStream
in an OutputStream
.
At the end of the copy, the streams are not closed.
in
- stream to readout
- stream to write
IOException
- if I/O errors occourpublic static void cp(File inFile, File outFile) throws IOException
inFile
- file to be copiedoutFile
- file in which to copy
FileNotFoundException
- if inFile does not exist
IOException
- if I/O errors occourpublic static void print(InputStream in)
System.out
.
This method is suitable if the input stream is a character stream.
in
- an InputStream to readpublic static boolean mv(File from, File to) throws IOException
File.renameTo(java.io.File)
;
if this fail, a copy is made and the original file is deleted.
Note: if the original file can not be deleted, the method actually makes a copy.
from
- file to moveto
- new file position
FilenotFoundException
- if file from does not exist
IOException
- if I/O errors occourpublic static int getUnsignedInt(byte b)
b
- a byte
|
andyLib v0.9.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |