Friday, October 24, 2014

read from file input
















The program is reading from file input. how can I replace hate with love















the file contains only one line















I hate programing!
















import java.util.Scanner;















import java.io.FileInputStream;















import java.io.FileNotFoundException;
















public class Program3 {















public static void main(String[] args) {















Scanner fileIn = null;
















try {















fileIn = new Scanner(new FileInputStream(















"C://Users//skalem//Desktop//program3.txt"));
















}
















catch (FileNotFoundException e) {
















System.out.println("File not ound");















System.exit(0);
















}
















String sentence = fileIn.next() + " " + fileIn.next() + " "















+ fileIn.next();
















System.out.println(sentence);
















}















output















I hate programming!































No comments:

Post a Comment