data creation in java | Sololearn: Learn to code for FREE!


data creation in java

whats the error with this didnt work on my ide

10/3/2020 2:29:25 PM


2 Answers

New Answer


For first one Scanner sc=new Scanner(; //object of Scanner class System.out.print("Enter the file name: "); String name=sc.nextLine(); //variable name to store the file name try (FileOutputStream fos = new FileOutputStream(name, true)){ System.out.print("Enter file content: "); String str=sc.nextLine()+"\n"; //str stores the string which we have entered byte[] b= str.getBytes(); //converts string into bytes fos.write(b); //writes bytes into file //close the file System.out.println("file saved."); fos.close(); } catch(Exception e) { System.out.println(e.toString()); }


didnt work too cuma tekin Topuz