Created
March 5, 2017 15:45
-
-
Save vs9390/f9571628944023dc9c2016db288204ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
class DemoWriteFile { | |
public static void main(String args[]) { | |
FileOutputStream fos = null; | |
BufferedReader br = null; | |
String str; | |
System.out.print("Press * to end"); | |
try { | |
fos = new FileOutputStream(args[0]); | |
br = new BufferedReader(new InputStreamReader(System.in)); | |
do { | |
str = br.readLine(); | |
byte b[] = str.getBytes(); | |
fos.write(b); | |
} while (!str.equals("*")); | |
fos.close(); | |
} catch (IOException e) { | |
System.out.println(" " + e); | |
} | |
System.out.print("file created successfully"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment