Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void makeObscure() throws IOException {
- File obscure = new File("C:\\Users\\Greattech\\Downloads\\obscure.txt");
- FileReader fileReader = new FileReader("C:\\Users\\Greattech\\Downloads\\lovecraft.txt");
- Scanner readFile = new Scanner(fileReader);
- FileWriter printer = null;
- String currentRow = "";
- String newRow = "";
- StringBuilder builder = new StringBuilder(currentRow);
- int ascii = 0;
- char newchar;
- if(!obscure.exists()){
- obscure.createNewFile();
- }else{
- //File already exists
- }
- try{
- printer = new FileWriter(obscure);
- throw new FileNotFoundException("File not found");
- } catch (FileNotFoundException | UnsupportedEncodingException e) {
- e.getMessage();
- }
- while(readFile.hasNextLine()){
- currentRow = readFile.nextLine();
- for (int i = 0; i < currentRow.length(); i++) {
- ascii = (int) currentRow.charAt(i);
- ascii += 3;
- newchar = (char) ascii;
- builder.insert(i,newchar);
- newRow = builder.toString();
- printer.write(newRow);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement