Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Apr 6th, 2020 136 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Name: Habib,Md Amir
  2. //ID: 19-41429-3
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.io.FileWriter;
  6. import java.io.FileReader;
  7. import java.io.File;
  8. import java.io.BufferedReader;
  9. import java.util.Scanner;
  10. public class Main{
  11.     public static void main(String[]args){
  12.         File myFile = new File("C:\\Users\\Asus\\Desktop\\file\\data.txt");
  13.         private Scanner y = new Scanner(myFile);
  14.         try{
  15.             myFile.createNewFile();
  16.             System.out.println("File Exists : "+myFile.exists());
  17.             System.out.println("File Path : "+myFile.getPath());
  18.             System.out.println("File Name : "+myFile.getName());
  19.             System.out.println("File Write : "+myFile.canWrite());
  20.         }
  21.         catch(IOException io){
  22.             System.out.println("IOException caught");
  23.         }
  24.         FileWriter fileWriter= null;
  25.         try{
  26.             fileWriter = new FileWriter(myFile, true);
  27.             String l = "Lab task on file system \n";
  28.             String l1 = "Step-1:Create a file \n";
  29.             String l2 = "Step-2:Write \n";
  30.             String l3 = "Step-3:Read \n";
  31.             String l4 = "Step-4:Buffered \n";
  32.             String l5 = "Step-5:Search keyword \n";
  33.             fileWriter.write(l);
  34.             fileWriter.write(l1);
  35.             fileWriter.write(l2);
  36.             fileWriter.write(l3);
  37.             fileWriter.write(l4);
  38.             fileWriter.write(l5);
  39.         }
  40.         catch(IOException io){
  41.             System.out.println("IOException caught");
  42.         }
  43.         try{
  44.             fileWriter.close();
  45.         }
  46.         catch(IOException io){
  47.             System.out.println("Can not close");
  48.         }
  49.         FileReader fileReader= null;
  50.         try{
  51.             fileReader = new FileReader(myFile);
  52.             int i=0;
  53.             while((i=fileReader.read())!=-1){
  54.                 System.out.print((char)i+"");
  55.             }
  56.         }
  57.         catch(IOException io){
  58.             System.out.println("IOException caught");
  59.         }
  60.         try{
  61.             fileReader.close();
  62.         }
  63.         catch(IOException io){
  64.             System.out.println("Can not close");
  65.         }
  66.         BufferedReader bufferedReader = null;
  67.         try{
  68.             bufferedReader = new BufferedReader(fileReader);
  69.             String line = "";
  70.             while((line = bufferedReader.readLine()) != null) {
  71.                 System.out.println(line);
  72.             }  
  73.         }
  74.          catch(IOException io) {
  75.             System.out.println("IOException handled");
  76.         }
  77.         finally {
  78.             try {
  79.                 fileReader.close();
  80.                 bufferedReader.close();
  81.             }
  82.             catch(IOException io) {
  83.                 System.out.println("Can not close");
  84.             }
  85.         }
  86.        
  87.         while(y.hasNext()) {
  88.            
  89.             a = y.next();
  90.             if (a == string) {
  91.                 do something
  92.             }
  93.         }
  94.     }      
  95. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top