Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to open a plain text file in Java?
You can access a plain text using the File class.
Example
import java.io.File;
public class ReadFile {
public static void main(String[] args) {
File f = null;
String str = "data.txt";
try {
f = new File(str);
boolean bool = f.canExecute();
String a = f.getAbsolutePath();
System.out.print(a);
System.out.println(" is executable: "+ bool);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Output
C:\Users\data is executable: true
Advertisements