diff --git a/bin/dam/daw/com/es/HolaFichero.class b/bin/dam/daw/com/es/HolaFichero.class index 8b48b11..c522253 100644 Binary files a/bin/dam/daw/com/es/HolaFichero.class and b/bin/dam/daw/com/es/HolaFichero.class differ diff --git a/src/dam/daw/com/es/HolaFichero.java b/src/dam/daw/com/es/HolaFichero.java index 04e3d88..4cafd6e 100644 --- a/src/dam/daw/com/es/HolaFichero.java +++ b/src/dam/daw/com/es/HolaFichero.java @@ -4,9 +4,13 @@ import java.io.File; import java.io.IOException; public class HolaFichero { + private static File directorioWindow = new File("C:\\Users\\AntonioFrische\\OneDrive - ABACCO Solutions\\Documents\\Schule_22_23_CFGS\\Acceso_Datos\\SpringTool_4"); + private static File directorioLinux = new File("/home/user"); - public static void main(String args[]) { + + public static void main(String args[]) throws IOException { char sisChar = systemCheck(); + crearFichero(sisChar); } @@ -21,4 +25,23 @@ public class HolaFichero { } return osChar; } + public static void crearFichero(char sisChar) throws IOException { + if(sisChar == 'W') { + System.out.println("Creando fichero en Windows ..."); + File newFichero = new File (directorioWindow+File.separator+"HolaFichero.txt"); + if (!newFichero.exists()) { + newFichero.createNewFile(); + } + System.out.println("Fichero creado en Windows."); + } + else { + System.out.println("Creando fichero en Linux ..."); + File newFichero = new File (directorioLinux+File.separator+"HolaFichero.txt"); + if (!newFichero.exists()) { + newFichero.createNewFile(); + } + System.out.println("Fichero creado en Linux."); + } + + } }