Advertisement
Marin126

31/3/2020 17:51

Mar 31st, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1.  
  2. import java.io.*;
  3. import java.util.Scanner;
  4.  
  5. /*
  6. * To change this license header, choose License Headers in Project Properties.
  7. * To change this template file, choose Tools | Templates
  8. * and open the template in the editor.
  9. */
  10. /**
  11. *
  12. * @author anton
  13. */
  14. public class Cifrado {
  15.  
  16. public static void main(String[] args) {
  17. Scanner sc = new Scanner(System.in);
  18. // String texto = "";
  19. String nombre;
  20. StringBuilder linea = new StringBuilder();
  21. int clave;
  22.  
  23. if (args.length == 0) {
  24. nombre = "C:\\Users\\anton\\Documents\\Proramacion\\CSVs\\texto.txt";
  25. clave = 1;
  26. } else {
  27. nombre = args[0];
  28. clave = Integer.parseInt(args[1]);
  29. }
  30. File f = new File(nombre);
  31. if (!f.exists()) {
  32. System.out.println("El fichero no existe");
  33. } else {
  34. Scanner scFile = null;
  35. try {
  36. scFile = new Scanner(f);
  37. while (scFile.hasNextLine()) {
  38. linea.append(scFile.nextLine() + "\n");
  39.  
  40. }
  41. } catch (Exception e) {
  42. System.out.println("Se ha producido un error");
  43. }
  44. }
  45. System.out.println(linea.toString());
  46. System.out.println(Utils.cifradoCesar(linea, clave));
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement