Scan to open on your phone
Point a camera at the QR code - it opens this exact paste, no app needed.
https://codepastes.com/zzgt0fa86w5dsw4sprg10oopsPlain Text
package ISE206;
import java.io.*;
public class prg10 {
public static void main(String[] args) {
String fileName="student.txt";
try
{
FileOutputStream fout=new FileOutputStream(fileName);
String data="Name:Shankar\n"+"Department:Information Science\n"+"Subject:java\n";
byte[] bytes=data.getBytes();
fout.write(bytes);
fout.close();
System.out.println("Data written successfully.");
}
catch(IOException e)
{
System.out.println("Error while writing to file:" +e);
}
try
{
FileInputStream fin=new FileInputStream(fileName);
int ch;
System.out.println("\n Data read from the file:");
while((ch=fin.read())!=-1)
{
System.out.print((char)ch);
}
fin.close();
}
catch(IOException e)
{
System.out.println("Error while reading from file:"+e);
}
}
}
765 chars · codepastes.com