Tuesday, 17 January 2023

Write a ‘java’ program to display characters from ‘A’ to ‘Z’. Write a ‘java’ program to copy only non-numeric data from one file to another file.

Write a ‘java’ program to display characters from ‘A’ to ‘Z’.

 import java.io.*;

 class Main {

  public static void main(String[] args) {

     char c;

 for(c = 'A'; c <= 'Z'; ++c)

      System.out.print(c + " ");

    }

}

Write a ‘java’ program to copy only non-numeric data from one file to another file.

 import java.io.*; 

import java.util.*; 

class Copyfile { 

 public static void main(String arg[]) throws Exception { 

  Scanner sc = new Scanner(System.in); 

  System.out.print("source file name :"); 

  String sfile = sc.next(); 

  System.out.print("destination file name :"); 

  String dfile = sc.next(); 

  FileReader fin = new FileReader(sfile); 

  FileWriter fout = new FileWriter(dfile, true); 

  int c; 

  while ((c = fin.read()) != -1) { 

   fout.write(c); 

  } 

  System.out.println("Copy finish..."); 

  fin.close(); 

  fout.close(); 

 } 

}