Showing posts with the label File and IO ProgramsShow all

6) Write a Java Program that reads a file, converts each tab character to a space character, and writes its output to another file , both files passed through CMD line.

source file name:    TabsDemo.java import java.io.*; public class TabsDemo { public static void main(String[]args) { File infile=new File(args[0]); File outfile=new File(args[1]); FileReader ins=null; FileWriter fos=null; int cnt=0; try{ ins=new FileReader(infile); fos=new FileWriter(outfile); int ch;  while((ch=ins.r…

Read more

5) Write Java Program writes the first 15 numbers of the Fibonacci series to a file and reads this data from a file and display it , files names passed through CMD line.

Write an application that writes the first 15 numbers of the Fibonacci series to a file .Write a second application that reads this data from a file and display it. For both application, specify, the name of the file  as command-line argument. source file name:  fibfilewrite.java   import java.io.*; class fibfilewrit…

Read more

4) Copy contains one file to another file.

import java.io.*; class filedemo1 { public static void main(String as[]) { System.out.println("file related program"); int n; try { FileInputStream fis=new FileInputStream("input.txt"); FileOutputStream fos=new FileOutputStream("newdata.txt");   int c;       …

Read more

3) Write a program that display Directory or File .

The  program should accept command line argument,  if  it file then File name display and if it Directory then contains of directory  is displays.   import java.io.*; public class FileDemo {      public static void main(String as[])     {         File f=null;       try { f=new File(as[0]); System…

Read more