You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.4 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. package dam.daw.com.es;
  2. import java.io.File;
  3. import java.io.IOException;
  4. public class HolaFichero {
  5. static char Sistema;
  6. public static void main(String args[]) throws IOException {
  7. char Sistema=MiSistema();
  8. System.out.println(Sistema);
  9. }
  10. static char MiSistema() throws IOException {
  11. char Sis='?';
  12. char Windows='W';
  13. char Linux='L';
  14. System.out.println("Creando mi primer fichero ...");
  15. String so = System.getProperty("os.name");
  16. System.out.print("El sistema operativo es: ");
  17. if (so.charAt(0)==Windows) {
  18. System.out.print("Windows -> ");
  19. Sis=Windows;
  20. CreoFicheroWindows();
  21. }
  22. else {
  23. System.out.print("Linux -> ");
  24. Sis=Linux;
  25. }
  26. return Sis;
  27. }
  28. public static void CreoFicheroWindows() throws IOException {
  29. System.out.println("Creando fichero en Windows ...");
  30. File fwindows = new File("C:\\Users\\kevin\\Documents\\CreoFicheroWindows.txt");
  31. if (!fwindows.exists()) {
  32. fwindows.createNewFile();
  33. }
  34. System.out.println("Fichero creado en Windows.");
  35. }
  36. public void CreoFicheroLinux() throws IOException {
  37. System.out.println("Creando fichero en Linux ...");
  38. File funix = new File("/home/..../CreoFicheroUnix.txt");
  39. if (!funix.exists()) {
  40. funix.createNewFile();
  41. }
  42. System.out.println("Fichero creado en Unix.");
  43. }
  44. }