Advertisement
Guest User

encrypt3

a guest
Feb 7th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3. public class encryptfiletext
  4. {
  5.  
  6.     public static void main (String [] arg) throws IOException{
  7.  
  8.     Scanner filscan = new Scanner (new File("klasslista.txt"));
  9.     File file = new File("krypteradfil.txt");
  10.     file.createNewFile();
  11.     PrintWriter writer = new PrintWriter("krypteradfil.txt", "UTF-8");
  12.     //writer.write("asdasd");
  13.     //writer.close();
  14.  
  15.     while(filscan.hasNext())
  16.         {  
  17.         String line = filscan.nextLine();  
  18.         String krypt_text=encrypt(line);
  19.         System.out.println(krypt_text);
  20.         writer.print(krypt_text);
  21.         writer.close();
  22.         }
  23.     }
  24.    
  25.    
  26.         public static String encrypt( String line){
  27.             //Random rng= new Random();
  28.             String krypt_text= ""; 
  29.         for(int i=0;i<line.length();i++){
  30.         int ascii_ny=(int)line.charAt(i)+1;
  31.         krypt_text=krypt_text+((char)ascii_ny);
  32.             }
  33.         return krypt_text;
  34.         }
  35.  
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement