Class Utf8FileWriter
Defines a writer class for UTF8-encoded files.
Inheritance
Inherited Members
Namespace: Juhta.Net.Common
Assembly: Juhta.Net.dll
Syntax
public class Utf8FileWriter
Constructors
| Improve this Doc View SourceUtf8FileWriter(String)
Initializes a new instance.
Declaration
public Utf8FileWriter(string filePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | Specifies the ablosute or a relative path of a UTF8-encoded file where data will be written. If the file already exists, it will be overwritten. |
Utf8FileWriter(String, FileMode)
Initializes a new instance.
Declaration
public Utf8FileWriter(string filePath, FileMode openMode)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | Specifies the ablosute or a relative path of a UTF8-encoded file where data will be written. |
System.IO.FileMode | openMode | Specifies how the UTF8-encoded file should be opened. |
Properties
| Improve this Doc View SourceFilePath
Gets the absolute path of the underlying UTF8-encoded file.
Declaration
public string FilePath { get; }
Property Value
Type | Description |
---|---|
System.String |
IndentLevel
Gets or sets the current indent level.
Declaration
public byte IndentLevel { get; set; }
Property Value
Type | Description |
---|---|
System.Byte |
Remarks
The result of the multiplication of IndentLevel and TabSize determines the number of space characters to write at the beginning of each new line.
See Also
| Improve this Doc View SourceTabSize
Gets or sets the current tab size.
Declaration
public byte TabSize { get; set; }
Property Value
Type | Description |
---|---|
System.Byte |
See Also
Methods
| Improve this Doc View SourceClose()
Flushes all unwritten data to the underlying UTF8-encoded file, and after that, closes the file.
Declaration
public void Close()
Remarks
This method does nothing if the underlying UTF8-encoded file is not open.
See Also
| Improve this Doc View SourceDecreaseIndentLevel()
Decreases the current indent level by one.
Declaration
public void DecreaseIndentLevel()
Flush()
Flushes all unwritten data to the underlying UTF8-encoded file.
Declaration
public void Flush()
Remarks
This method does nothing if the underlying UTF8-encoded file is not open.
IncreaseIndentLevel()
Increases the current indent level by one.
Declaration
public void IncreaseIndentLevel()
Open()
Opens the underlying UTF8-encoded file.
Declaration
public void Open()
Remarks
This method does nothing if the underlying UTF8-encoded file is already open.
This method does not necessarily have to be called when writing data to the underlying UTF8-encoded file. If the file is not open, it will be automatically opened and closed in context of each write operation. However, recurrent openings and closings of the file might cause some performance loss. To gain the maximum performance, the file should be opened with an explicit call on this method prior to write operations. In this case, the file must also be explicitly closed with the Close() method.
See Also
| Improve this Doc View SourceWrite(String)
Writes a specified string to the underlying UTF8-encoded file.
Declaration
public void Write(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | Specifies a string. |
Write(String, Object[])
Writes a formatted string to the underlying UTF8-encoded file.
Declaration
public void Write(string format, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | Specifies a string containing zero or more format items. |
System.Object[] | args | Specifies an object array containing zero or more objects to format. These objects must
correspond to the format items in |
WriteLine()
Writes a line terminator to the underlying UTF8-encoded file.
Declaration
public void WriteLine()
WriteLine(Int32)
Writes a specified number of line terminators to the underlying UTF8-encoded file.
Declaration
public void WriteLine(int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | count | Specifies a number of line terminators to write. |
WriteLine(String)
Writes a specified string followed by a line terminator to the underlying UTF8-encoded file.
Declaration
public void WriteLine(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | Specifies a string. |
WriteLine(String, Object[])
Writes a formatted string followed by a line terminator to the underlying UTF8-encoded file.
Declaration
public void WriteLine(string format, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | Specifies a string containing zero or more format items. |
System.Object[] | args | Specifies an object array containing zero or more objects to format. These objects must
correspond to the format items in |