//for I/O package untitled4; import java.io.*; import java.util.*; import javax.swing.JOptionPane; public class labsix { public static void main(String[] args) throws IOException { String Str,temp,SingleWord,newLine; //for input BufferedReader b; //for output PrintWriter w; //indicator for uppercase letter boolean Uppercase=false; try{ System.out.println("Please enter input file name"); Str=SavitchIn.readLine(); b = new BufferedReader(new FileReader(Str)); System.out.println("Please enter output filename"); Str=SavitchIn.readLine(); w = new PrintWriter(new FileOutputStream(Str)); //get each line in the input file //temp=b.readLine(); while((temp=b.readLine())!=null) { //get all words using StringTokenizer in temp StringTokenizer sT; sT=new StringTokenizer(temp); newLine=" "; while (sT.hasMoreTokens()) { // true while there are more words in sentence SingleWord = sT.nextToken().trim(); // gets the next word //construct the new line if(Uppercase==true) { //change first letter to uppercase SingleWord=(SingleWord.charAt(0)+"").toUpperCase()+SingleWord.substring(1); Uppercase=false; } newLine+=SingleWord+" "; //check for '.','!','?' if(SingleWord.charAt(SingleWord.length()-1)=='.' || SingleWord.charAt(SingleWord.length()-1)=='!' || SingleWord.charAt(SingleWord.length()-1)=='?') Uppercase=true; } w.println(newLine.trim()); } b.close(); w.close(); } catch(FileNotFoundException e) { System.out.println("File opening problem"); } catch(IOException e) { System.out.println("IO Exception!"); } } }