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



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. awesome.........
View Tutorial          By: tar at 2013-03-14 07:36:56

2. It is simple and clear.. Thnx.
View Tutorial          By: kiru at 2010-04-06 01:48:04

3. write the program to convert the following:

View Tutorial          By: belgreen frodo at 2015-03-31 05:53:21

4. hello
thanks for your code. Please could an

View Tutorial          By: Bruno at 2009-05-28 15:38:46

5. can i have sample of java programming that has dat
View Tutorial          By: piolo at 2009-05-31 18:53:25

6. how we can store a pdf file into database

View Tutorial          By: neelima at 2010-03-10 23:46:52

7. help to place a menu inside a menu
View Tutorial          By: sandy at 2009-07-29 05:57:28

8. please give me more information
View Tutorial          By: nandhini at 2012-09-22 03:49:11

9. well,its better to teach with video how it works
View Tutorial          By: c.muthukumar at 2010-09-22 07:28:24

10. I got intersting idea about gauge,thanks...
View Tutorial          By: Marimuthu at 2009-07-20 00:56:27