Java I/O Programming: Exercises, Practice, Solution
Java Input-Output Exercises [18 exercises with solution]
1. Write a Java program to get a list of all file/directory names from the given. Go to the editor
Click me to see the solution
2. Write a Java program to get specific files by extensions from a specified folder. Go to the editor
Click me to see the solution
3. Write a Java program to check if a file or directory specified by pathname exists or not. Go to the editor
Click me to see the solution
4. Write a Java program to check if a file or directory has read and write permission. Go to the editor
Click me to see the solution
5. Write a Java program to check if given pathname is a directory or a file. Go to the editor
Click me to see the solution
6. Write a Java program to compare two files lexicographically. Go to the editor
According to Wikipedia:
In mathematics, the lexicographic or lexicographical order (also known as lexical order, dictionary order, alphabetical order or lexicographic(al) product) is a generalization of the way the alphabetical order of words is based on the alphabetical order of their component letters. This generalization consists primarily in defining a total order over the sequences (often called words in computer science) of elements of a finite totally ordered set, often called alphabet.
Click me to see the solution
7. Write a Java program to get last modified time of a file. Go to the editor
Click me to see the solution
8. Write Java program to read input from java console. Go to the editor
Click me to see the solution
9. Write a Java program to get file size in bytes, kb, mb. Go to the editor
Click me to see the solution
10. Write a Java program to read contents from a file into byte array. Go to the editor
Click me to see the solution
11. Write a Java program to read a file content line by line. Go to the editor
Click me to see the solution
12. Write a Java program to read a plain text file. Go to the editor
Click me to see the solution
13. Write a java program to read a file line by line and store it into a variable. Go to the editor
Click me to see the solution
14. Write a Java program to store text file content line by line into an array. Go to the editor
Click me to see the solution
15. Write a Java program to write and read a plain text file. Go to the editor
Click me to see the solution
16. Write a Java program to append text to an existing file. Go to the editor
Click me to see the solution
17. Write a Java program to read first 3 lines from a file. Go to the editor
Click me to see the solution
18. Write a Java program to find the longest word in a text file. Go to the editor
Click me to see the solution
Java Code Editor
More to Come !
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
Java: Tips of the Day
How to sort an ArrayList?
Collections.sort(testList); Collections.reverse(testList);
That will do what you want. Remember to import Collections though!
Ref: https://bit.ly/32urdSe
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework