java.io


1. Reading Text from a File

try {
    BufferedReader reader = new BufferedReader(new FileReader("file.txt"));
    String line;
    while ((line = reader.readLine()) != null) {
        System.out.println(line);
    }
    reader.close();
} catch (IOException e) {
    e.printStackTrace();
}

2. Writing Text to a File

try {
    BufferedWriter writer = new BufferedWriter(new FileWriter("file.txt"));
    writer.write("Hello world!");
    writer.close();
} catch (IOException e) {
    e.printStackTrace();
}

3. Reading Binary Data from a File

4. Writing Binary Data to a File

5. Serializing an Object

6. Deserializing an Object

7. Reading from a URL

8. Writing to a URL

9. Reading from a String

10. Writing to a String

11. Reading from a ByteArrayInputStream

12. Writing to a ByteArrayOutputStream

13. Reading from a PipedInputStream

14. Writing to a PipedOutputStream

15. Reading from a FilterInputStream

16. Writing to a FilterOutputStream

17. Reading from a PushbackInputStream

18. Writing to a PushbackOutputStream

19. Reading from a LineNumberInputStream

20. Writing to a LineNumberOutputStream

21. Reading from a SequenceInputStream

22. Writing to a PipedWriter

23. Reading from a CharArrayReader

24. Writing to a CharArrayWriter

25. Reading from a StringReader

26. Writing to a FileWriter

27. Reading from a FileReader

28. Creating a DataInputStream from a File

29. Creating a DataOutputStream from a File

30. Creating a BufferedReader from a String

31. Creating a BufferedWriter from a String

32. Creating a FilterInputStream from a File

33. Creating a FilterOutputStream from a File

34. Creating a PushbackInputStream from a File

35. Creating a PushbackOutputStream from a File

36. Creating a LineNumberInputStream from a File

37. Creating a LineNumberOutputStream from a File

38. Creating a SequenceInputStream from multiple Files

39. Creating a PipedInputStream and PipedOutputStream

40. Creating a CharArrayReader from a char array

41. Creating a CharArrayWriter

42. Creating a StringReader from a String

43. Creating a FileWriter

44. Creating a FileReader

45. Using a FileInputStream to read a file into a byte array

46. Using a FileOutputStream to write a byte array to a file

47. Using a StringReader to read a string into a character array

48. Using a StringWriter to write a character array to a string

49. Using a PipedInputStream and PipedOutputStream to communicate between threads

50. Using a FileChannel to read and write data to a file