-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpperCaseFileConverter.java
72 lines (44 loc) · 1.67 KB
/
UpperCaseFileConverter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Sam Colburn
// 1-30-2015
// CS110
// 4-15:Upper Case File Converter
//Write a program that asks the user to enter the name of an input file,
//Write a program that asks the user to enter the name of an output file,
//The program should convert all characters in the input file to uppercase and store them in the output fil.
// NOTES:
// -input and output using JOptionPane
// import libraries
import java.util.Scanner;
import javax.swing.JOptionPane;
import java.io.*;
//START CLASS UpperCaseFileConverter
public class UpperCaseFileConverter{
//START METHOD main
public static void main(String [] args)throws IOException{
//initialize variables
String inFileName;
String outFileName;
String input;
String output;
//GET the file names
inFileName = JOptionPane.showInputDialog ("Enter the input file name: ");
outFileName = JOptionPane.showInputDialog ("Enter the output file name: ");
//OPEN the input file
File inputFile = new File(inFileName);
Scanner inFile = new Scanner(inputFile);
// Open output the file.
PrintWriter outFile;
outFile = new PrintWriter(outFileName);
//loop through the file until it ends
while (inFile.hasNext()){
input = inFile.nextLine();
output = input.toUpperCase();
outFile.println(output);
}//end while loop
// Close the files.
inFile.close();
outFile.close();
//DISPLAY message of completion.
JOptionPane.showMessageDialog(null,"Done");
}//END METHOD main
}//END CLASS UpperCaseFileConverter