Commit 491cb8c
committed
docs: add notes on serialization and file permission handling in Java
WHAT:
- Documented core concepts of object serialization and deserialization.
- Added explanation of the `Serializable` interface and behavior of `transient` and `static` fields.
- Summarized file permission methods available in the `File` class (`canRead`, `canWrite`, `canExecute`).
- Included example usage for checking and modifying file permissions.
WHY:
- Serialization is essential for persisting and transmitting objects (e.g., saving to files, sending over a network).
- File permission methods are critical for secure file handling and preventing unauthorized access.
- Developers need a concise reference for these common Java I/O practices.
KEY POINTS:
- Serialization:
- Converts an object into a byte stream.
- Deserialization reconstructs the object from the stream.
- `transient` fields are skipped, `static` fields are not serialized.
- File Permissions:
- `canRead()`, `canWrite()`, `canExecute()` → check existing permissions.
- `setReadable()`, `setWritable()`, `setExecutable()` → modify permissions.
- Behavior is OS-dependent and subject to Java Security Manager restrictions.
REAL-WORLD USE CASES:
- Serialization: Storing user sessions, caching objects, or transmitting data between distributed systems.
- File Permissions: Enforcing read-only configuration files, restricting log file edits, or controlling executable scripts.
NOTES:
- Always ensure serialVersionUID is defined in Serializable classes for version consistency.
- Permission methods may succeed or fail depending on the OS-level policies, not just Java code.
Signed-off-by: https://github.com/Someshdiwan <[email protected]>1 parent e9e5eea commit 491cb8c
File tree
1 file changed
+3
-3
lines changed- Section23JavaIOStreams/Serialisation Storing Data in a File/src
1 file changed
+3
-3
lines changedLines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | | - | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | | - | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
0 commit comments