java.io.File ক্লাস ফাইল/ডিরেক্টরির পাথ রিপ্রেজেন্ট করে। মূল কনস্ট্রাক্টর:
File(String pathname)File(String parent, String child)File(File parent, String child)File(URI uri)
সাধারণ মেথড
getName()- ফাইল নামgetPath()- পাথgetAbsolutePath()- অ্যাবসোলিউট পাথgetParent()- প্যারেন্ট ডিরেক্টরিexists()- এক্সিস্ট চেকcanRead(),canWrite()- পারমিশনlength()- ফাইল সাইজ (বাইটে)
উদাহরণ
import java.io.File;
public class FileDemo {
public static void main(String[] args) {
if (args.length == 0) return;
File file = new File(args[0]);
System.out.println("ফাইল নাম: " + file.getName());
System.out.println("পাথ: " + file.getPath());
System.out.println("অ্যাবসোলিউট পাথ: " + file.getAbsolutePath());
System.out.println("প্যারেন্ট ডিরেক্টরি: " + file.getParent());
if (file.exists()) {
System.out.println("রিডেবল: " + file.canRead());
System.out.println("সাইজ (বাইট): " + file.length());
}
}
}