
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
- Related Questions & Answers
- How to open a plain text file in C#?
- Print plain text in Arduino
- How to open a file to write in Python?
- Reading a Text file in java
- How to open a file just to read in python?
- How to append text to a text file in C++?
- How to open hidden file using C#?
- How to open a file in binary mode with Python?
- How to open a file in append mode with Python?
- How to find the Strings within a text file in Java?
- How to open and close a PDF file using Swift?
- How to open a binary file in append mode with Python?
- How to open multiple files using a File Chooser in JavaFX?
- How to Install Best Open Source Text Editors
- How to read a text file in Python?
Advertisements