- 4

import java.io.*; public class BinaryFileDemo { public static void main(String[] args) { FileOutputStream outobject

import java.io.*; public class BinaryFileDemo { public static void main(String[] args) { FileOutputStream outobject = null; FileInputStream inobject = null; String cities = "mumbai\n delhi\n chennai\n mathura\n pune\n"; byte citiesarray[] = cities.getBytes(); try{ outobject = new FileOutputStream("Binaryfile.dat"); outobject.write(citiesarray); outobject.close(); inobject = new FileInputStream("Binaryfile.dat"); int i; while((i=inobject.read())!=-1) { System.out.print((char)i); } inobject.close(); } catch(Exception eobj) { System.out.println(eobj); } } }

31st Dec 2020, 3:19 AM
Jibon Kumar
Jibon Kumar - avatar
1 Resposta
+ 1
Jibon Kumar What is the problem here?
31st Dec 2020, 3:40 AM
A͢J
A͢J - avatar