Browse Source

commit añadir main

master
JoanMoncho 2 years ago
commit
43a3ae1a70
9 changed files with 217 additions and 0 deletions
  1. +29
    -0
      .gitignore
  2. +6
    -0
      .idea/misc.xml
  3. +8
    -0
      .idea/modules.xml
  4. +6
    -0
      .idea/vcs.xml
  5. +76
    -0
      .idea/workspace.xml
  6. +11
    -0
      Actividad8.1.iml
  7. +11
    -0
      README.md
  8. +28
    -0
      src/Main.java
  9. +42
    -0
      src/Persona.java

+ 29
- 0
.gitignore View File

@ -0,0 +1,29 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

+ 6
- 0
.idea/misc.xml View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="openjdk-19" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

+ 8
- 0
.idea/modules.xml View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Actividad8.1.iml" filepath="$PROJECT_DIR$/Actividad8.1.iml" />
</modules>
</component>
</project>

+ 6
- 0
.idea/vcs.xml View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

+ 76
- 0
.idea/workspace.xml View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="4717f6a0-a6f8-4348-95fd-a166783ad8ed" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Actividad8.1.iml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Main.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Persona.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="2I3NecE37I09iVjoVzByIvc6PfS" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ASKED_ADD_EXTERNAL_FILES": "true",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
"nodejs_package_manager_path": "npm"
}
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="4717f6a0-a6f8-4348-95fd-a166783ad8ed" name="Changes" comment="" />
<created>1669406403496</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1669406403496</updated>
<workItem from="1669406404738" duration="1182000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
</project>

+ 11
- 0
Actividad8.1.iml View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

+ 11
- 0
README.md View File

@ -0,0 +1,11 @@
# Aplicación Spring Tool
1. Primero creamos un fichero llamado Persona.dat
2. Creamos el array de nombres de las personas, los apellidos y las edades.
3. Por ultimo usamos el .writeObject para añadir las lineas de cada array y lo cerramos con el .close
## RESULTADO:
```
Ha terminado el proceso correctamente.
```

+ 28
- 0
src/Main.java View File

@ -0,0 +1,28 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) throws IOException {
File fichero = new File("C:\\Users\\JoanMoncho\\Documents\\Personas.dat");
FileOutputStream fos = new FileOutputStream(fichero);
ObjectOutputStream oos = new ObjectOutputStream(fos);
//ArrayList<Persona> personas = new ArrayList<>();
String[] nombres= {"Joan","Sergi","Hector","Paco"};
String[] apellidos = {"Moncho","Signes","Ferrandiz","Mengual"};
int[] edades= {20,18,19,45};
oos.writeObject(nombres);
oos.writeObject(apellidos);
oos.writeObject(edades);
fos.close();
oos.close();
System.out.println("Ha terminado el proceso correctamente.");
}
}

+ 42
- 0
src/Persona.java View File

@ -0,0 +1,42 @@
import java.io.Serializable;
public class Persona implements Serializable {
private String nombre;
private String apellido;
private int edad;
public Persona(String nombre,String apellido, int edad) {
this.nombre = nombre;
this.apellido = apellido;
this.edad= edad;
}
public Persona() {
this.nombre=null;
}
public String getApellido() {
return apellido;
}
public void setApellido(String apellido) {
this.apellido = apellido;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public int getEdad() {
return edad;
}
public void setEdad(int edad) {
this.edad = edad;
}
}

Loading…
Cancel
Save