- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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
- Related Articles
- How to open a plain text file in C#?
- How to Convert Hyperlink to Plain Text in Excel?
- Print plain text in Arduino
- How to display HTML tags as plain text in HTML?
- Reading a Text file in java
- How to find the Strings within a text file in Java?
- How to open a file to write in Python?
- How to append text to a text file in C++?
- How to open a file just to read in python?
- How to open a file in binary mode with Python?
- How to open a file in append mode with Python?
- How to count the number of words in a text file using Java?
- How to count the number of lines in a text file using Java?
- How to use Boto3 to create a secret key as plain text in AWS Secret Manager
- How to read a text file in Python?

Advertisements