Answers for "file handling in java"

0

IO STREAMS in java

import java.io.*;
public class CopyFile {

   public static void main(String args[]) throws IOException {  
      FileInputStream in = null;
      FileOutputStream out = null;

      try {
         in = new FileInputStream("input.txt");
         out = new FileOutputStream("output.txt");
         
         int c;
         while ((c = in.read()) != -1) {
            out.write(c);
         }
      }finally {
         if (in != null) {
            in.close();
         }
         if (out != null) {
            out.close();
         }
      }
   }
}
Posted by: Guest on November-20-2020
1

file handling in java

import java.io.File;  // Import the File class

File myObj = new File("filename.txt"); // Specify the filename
Posted by: Guest on May-06-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language