12:25 am - Thursday June 29, 2017

FileOutputStream example program for getFD() () in java

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
 *@author: candidjava
 *@description: FileOutputStream example program for getFD()() in JAVA
 **/

import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileOutputStreamDemo {
	public static void main(String[] args) throws IOException {
		FileOutputStream fos = null;
		FileDescriptor fd = null;
		boolean bool = false;
		try {
			// create new file output stream
			fos = new FileOutputStream("C://test.txt");
			// get file descriptor instance
			fd = fos.getFD();
			// test if the file is valid
			bool = fd.valid();
			// print
			System.out.print("Is file valid? " + bool);
		} catch (Exception ex) {
			// if an error occurs
			ex.printStackTrace();
		} finally {
			if (fos != null)
				fos.close();
		}
	}
}

Output

is file valid? true

BACK

Filed in: Z-A All Java Codes

Comments are closed.