Posts

Showing posts with the label cpoyFIle

Java File Handling

 1. This program helps to create a new file , with their inner content:  package com.test.file ; import java.io.FileOutputStream ; import java.io.IOException ; import java.nio.charset.StandardCharsets ; import java.util.Scanner ; public class CreateNewFIleWithContent { public static void getFileCreated (){ Scanner sc = new Scanner ( System . in ); System . out . print ( " Enter the file name path : " ); String filePath = sc . nextLine (); filePath = filePath . replace ( "/" , " \\ " ); try { FileOutputStream fos = new FileOutputStream ( filePath , true ); System . out . print ( " Enter the content inside the file: " ); String content = sc . nextLine (); fos . write ( content . getBytes ()); fos . close (); } catch ( IOException e ){ e . printStackTrace (); } } public static void main ( String [] args ) {...