public final class FileWriting extends Object implements Closeable
Example:
final Media file = Medias.create("test.txt"); try (FileWriting writing = new FileWriting(file)) { writing.writeBoolean(true); writing.writeByte((byte) 1); writing.writeChar('c'); writing.writeShort((short) 2); writing.writeInteger(1); writing.writeFloat(5.1f); writing.writeLong(6L); writing.writeDouble(7.1); } catch (final IOException exception) { Assert.fail(exception.getMessage()); }
Constructor and Description |
---|
FileWriting(Media media)
Internal constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Terminate writing, close file.
|
void |
writeBoolean(boolean b)
Write a boolean (1 bit,
true or false ). |
void |
writeByte(byte b)
Write a byte (1 byte, -128 to 127 both included).
|
void |
writeChar(char c)
Write a char (2 bytes, 0 to 65535 both included).
|
void |
writeDouble(double d)
Write a double (8 bytes, 4.94065645841246544e-324 to 1.79769313486231570e+308).
|
void |
writeFloat(float f)
Write a float (4 bytes, 1.40129846432481707e-45 to 3.40282346638528860e+38).
|
void |
writeInteger(int i)
Write an integer (4 bytes, -2.147.483.648 to 2.147.483.647 both included).
|
void |
writeLong(long l)
Write a long (8 bytes, -9.223.372.036.854.775.808 to 9.223.372.036.854.775.807).
|
void |
writeShort(short s)
Write a short (2 bytes, -32.768 to 32.767 both included).
|
void |
writeString(String s)
Write a sequence of characters (2 bytes and more).
|
public FileWriting(Media media)
media
- The media path.LionEngineException
- If error when opening the media.public void writeBoolean(boolean b) throws IOException
true
or false
).b
- The boolean to writeIOException
- If write failed.public void writeByte(byte b) throws IOException
b
- The byte to write.IOException
- If write failed.public void writeChar(char c) throws IOException
c
- The char to write.IOException
- If write failed.public void writeShort(short s) throws IOException
s
- The short to write.IOException
- If write failed.public void writeInteger(int i) throws IOException
i
- The integer to write.IOException
- If write failed.public void writeFloat(float f) throws IOException
f
- The float to write.IOException
- If write failed.public void writeLong(long l) throws IOException
l
- The long to write.IOException
- If write failed.public void writeDouble(double d) throws IOException
d
- The double to write.IOException
- If write failed.public void writeString(String s) throws IOException
s
- The string to write.IOException
- If write failed.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
- If write failed.Copyright © 2017 Byron 3D Games Studio. All rights reserved.