File Handling
import java.io.*;
/**
*
* @author Manish Kumar
*/
public class ByteFileInp {
public static void main(String Mad[]){
try{
FileOutputStream
fout = new FileOutputStream("man.txt",true);
String
msz="Today you r cele";
byte arr[]=
msz.getBytes();
fout.write(arr);
fout.close();
FileInputStream finp = new FileInputStream("man.txt");
byte data[]
= new byte[finp.available()];
finp.read(data);
String str =
new String(data);
System.out.println(str);
finp.close();
}
catch(Exception e){
System.err.println("Error is Here"+e);
}
}
}
Another Program
import java.io.*;
class FileHand
{
public static void
main(String args[]){
try{
FileOutputStream
fout = new FileOutputStream("hello Manish",false);
String
msz="Today you r celebrating 68th Independence Day";
byte arr[]=
msz.getBytes();
fout.write(arr);
fout.close();
}
catch(Exception e){
System.out.println("Manish You Have Error");
}
}
}
No comments:
Post a Comment