Code:
import java.io.*;
public class Byte {
public static void main(String[] args)
{
String strFilePath = "D://p1.txt";
try
{
FileOutputStream fos = new FileOutputStream(strFilePath);
String strContent = "Saba Ayub Shaikh ";
fos.write(strContent.getBytes());
fos.close();
System.out.println("Data is written into the file
named as p1");
}
catch(FileNotFoundException ex)
{
System.out.println("FileNotFoundException : " +
ex);
}
catch(IOException ioe)
{
System.out.println("IOException : " + ioe);
}
}
}
Output:
Comments
Post a Comment