- Hello World
- Working with JSON Files
To get started with Kotlin, you can write a simple "Hello, World!" program.
- Data Structure with Kotlin Data Classes: Data Types, Classes, Properties
- Error Handling: Try-Catch, Null Safety
- File I/O: Reading and Writing Files
- Reading JSON Files
- Writing JSON Files
- Example: Reading and Writing JSON Files
- Balance Management: Balance, Income, Expense, DateTime
Data Structure Example:
{
"balance": 0,
"transactions": [
{"id": 1, "type": "income", "amount": 1000, "date": "2023-10-01T10:00:00", "description": "Salary"},
{"id": 2, "type": "expense", "amount": 200, "date": "2023-10-02T12:00:00", "description": "Groceries"}
],
"reports": {
"yearly": [
{
"year": "2022",
"totalIncome": 1200,
"totalExpense": 500,
"netBalance": 700
}
],
"monthly": [
{
"month": "2023-10",
"totalIncome": 1000,
"totalExpense": 200,
"netBalance": 800
}
]
}
}
Method | Input Type | Typical Use Case | Key Feature |
---|---|---|---|
writeText |
String |
Simple text files | One-liner, overwrites |
writeBytes |
ByteArray |
Binary data (images, PDFs) | Handles raw bytes |
printWriter |
Writer API | Formatted output (println/printf) | Easy formatting |
bufferedWriter |
Writer API | Large text files | Efficient buffered writes |