| 1234567891011121314151617181920212223242526272829 |
- import java.io.*;
- import java.util.Scanner;
- public class FileConverter {
- public static String covertFileToUpperCase(String fileFullPath) throws IOException{
- String content = readFile(fileFullPath);
- content = toUpperCase(content);
- return content;
- }
- public static String readFile(String fileFullPath) throws IOException{
- StringBuilder stringBuilder = new StringBuilder();
- File file = new File(fileFullPath);
- Scanner reader = new Scanner(file);
- while (reader.hasNextLine()) {
- stringBuilder.append(reader.nextLine());
- if(reader.hasNextLine())
- stringBuilder.append('\n');
- }
- reader.close();
- return stringBuilder.toString();
- }
- public static String toUpperCase(String content){
- return content.toUpperCase();
- }
- }
|