Posts

Showing posts with the label Java File Handling Tutorial

Handling Primitive Data Types in Java I/O जावा I/O में प्रिमिटिव डेटा टाइप्स को संभालना

Java provides special Data Streams to read and write primitive data types like int , float , boolean , and char . जावा डाटा स्ट्रीम्स प्रदान करता है जो प्रिमिटिव डेटा टाइप्स जैसे int , float , boolean , और char को पढ़ने और लिखने के लिए उपयोग होती हैं। Key Points / मुख्य बिंदु:- DataOutputStream writes primitive data types to a file. DataOutputStream फाइल में प्रिमिटिव डेटा टाइप्स लिखता है। DataInputStream reads primitive data types from a file. DataInputStream फाइल से प्रिमिटिव डेटा टाइप्स पढ़ता है। These are useful for structured data storage. यह स्ट्रक्चर्ड डेटा स्टोरेज के लिए उपयोगी हैं। 💻 Example 1: Writing Primitive Data Types import java.io.*; public class WritePrimitives { public static void main(String[] args) { try { FileOutputStream fos = new FileOutputStream("data.bin"); DataOutputStream dos = new DataOutputStream(fos); dos.writeInt(101); dos.writeUTF("Ajay"); ...

File Handling in Java जावा में फ़ाइल हैंडलिंग

File Handling in Java allows us to create, read, write, and manage files on the system. It is part of java.io package which provides multiple classes and methods to handle files. जावा में फ़ाइल हैंडलिंग के द्वारा हम सिस्टम पर फाइल को बनाना, पढ़ना, लिखना और प्रबंधित कर सकते हैं। यह java.io पैकेज का हिस्सा है जो फ़ाइल हैंडलिंग के लिए कई क्लास और मेथड उपलब्ध कराता है। 🔹 Common Classes for File Handling in Java Class Description (English) विवरण (Hindi) File Represents file or directory path फ़ाइल या डायरेक्टरी का प्रतिनिधित्व करता है FileReader Used to read data from a file character by character फ़ाइल को कैरेक्टर-बाय-कैरेक्टर पढ़ने के लिए FileWriter Used to write character data to a file फ़ाइल में कैरेक्टर डेटा लिखने के लिए BufferedReader Reads text efficiently line by line टेक्स्ट को लाइन-बाय-लाइन प्रभावी रूप से पढ़ता है BufferedWriter Writes text efficiently to a file टेक्स्ट को प्रभावी रूप से फ़ाइल में लिखता है FileInputStream Reads binary data...