Implementation

Storyboard

>Model

ID:(109, 0)


Reading File

Description

ID:(1272, 0)


Library for File Management

Description

ID:(2452, 0)


JFileChooser

Description

ID:(1275, 0)


Opening File

Description

ID:(1257, 0)


Interpreting Line

Description

ID:(1258, 0)


Ejemplo de uso de JFileChooser

Description

Un ejemplo que emplea JFileChooser para seleccionar un archivo es

```
package chooser;

import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JFrame;

public class SampleJFileChooser {

public SampleJFileChooser(){
JFileChooser jFileChooser = new JFileChooser();
jFileChooser.setCurrentDirectory(new File("/User/alvinreyes"));
int result = jFileChooser.showOpenDialog(new JFrame());

if (result == JFileChooser.APPROVE_OPTION) {

File selectedFile = jFileChooser.getSelectedFile();
System.out.println("Selected file: " + selectedFile.getAbsolutePath());
}
}
public static void main(String[] args) {
new SampleJFileChooser();
}
}
```

ID:(8863, 0)


Ejemplo de Lectura y Escritura

Description

La siguiente rutina lee un archivo y graba su contenido en un segundo archivo:

```
import java.io.*;

public class CopyFile {

public static void main(String args[]) throws IOException {
FileInputStream in = null;
FileOutputStream out = null;

try {
in = new FileInputStream("input.txt");
out = new FileOutputStream("output.txt");

int c;
while ((c = in.read()) != -1) {
out.write(c);
}
}finally {

if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
}
}
```

ID:(8864, 0)


XML DOM

Description

ID:(1273, 0)