Ok I have another homework problem. Essentially I am to make a text file of randomized characters ( leters bothe upper and lower case, numbers, spaces and specialized characters) and import it as a string into my program. From there I am to make all lowercase letters uppercase. I think I can handle the latter but the part I'm having issues with is bring in the file. I have looked through the forum and found some stuff about bufferereader and io exceptions thrown and null etc but that didn't make any sense plus that solution seemed very complicated for something that seems like it should be maybe 2 lines. I have some of the initial code:
package lab7a;
/**
*
* @author 24x24
*/
import java.util.Scanner;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String filePath = getFilePath();//gets the file path from user
String random = getString(filePath);//finds string from the filepath
String convert = convertString();//converts the lower case in string to uppercase
String write = writeString();//rewrites file
}
public static String getFilePath (){
System.out.print("Enter the file name: ");
Scanner keyboard = new Scanner(System.in);//user input for the file path
String filePath = keyboard.next();
return filePath;//returns filePath
}//end getFilePath
public static String getString (String filePath){
//this is where I am currently stuck
}//end getString
}
Once I get the string from the file I am assuming I can just use toUpper and it will only change the letters that are lower case. If not I could put the string into an array or something and search the array for letters that are equivalent to ascii values from a-z convert then copy it all to a new array, output as string and then write to file. I'm pretty certain I can figure that one out either way. Its the read from file issue that I'm in need of some assistance.
Thanks in advance,
24x24