Skip to content

Instantly share code, notes, and snippets.

@vs9390
Created March 5, 2017 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vs9390/f9571628944023dc9c2016db288204ca to your computer and use it in GitHub Desktop.
Save vs9390/f9571628944023dc9c2016db288204ca to your computer and use it in GitHub Desktop.
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