Comment on Tutorial - FileInputStream - sample program in Java By Sam Chen



Comment Added by : anne

Comment Added at : 2011-11-22 10:50:10

Comment on Tutorial : FileInputStream - sample program in Java By Sam Chen
You can save a file from the content of the input. This is my method to do it.

public static void SaveText() throws FileNotFoundException {
try {
System.out.println("Enter the string");
Scanner ip = new Scanner(System.in);
String str = ip.nextLine();
ip.close();

byte[] source = str.getBytes();
FileOutputStream fos = new FileOutputStream("D:/test.txt");
fos.write(source);
System.out.println("Finished");
} catch (IOException ex) {
Logger.getLogger(Q2.class.getName()).log(Level.SEVERE, null, ex);
}
}


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. hello

my problem is how to intrega

View Tutorial          By: mihir patel at 2013-11-28 18:10:04

2. This is the best example for beginners. After read
View Tutorial          By: BB at 2014-05-20 05:24:09

3. Hello sir pls send me
com.sun.speech.freet

View Tutorial          By: nikunj at 2011-08-19 06:55:37

4. Hi , it was nice tutorial to understand the differ
View Tutorial          By: jagan at 2014-06-05 05:13:59

5. Its very useful to me
View Tutorial          By: suba at 2011-07-04 11:21:19

6. Hi All,

This code is working fine i

View Tutorial          By: A.Balaji at 2010-09-27 04:40:38

7. Excellent Article.
View Tutorial          By: Praveen Kumar S at 2011-03-24 23:14:44

8. i want very simple & easy notes on php which u
View Tutorial          By: deepa at 2011-07-12 09:04:30

9. Excellent tutorial thank you very much.

View Tutorial          By: Edd at 2012-01-15 10:49:00

10. Hello,
I've tried the above code, but I've

View Tutorial          By: Phyo Phyo at 2009-09-14 05:32:28