Skip to content

Commit 831c7a6

Browse files
committed
final test
1 parent c169ee0 commit 831c7a6

15 files changed

Lines changed: 266 additions & 48 deletions

README.md

Whitespace-only changes.

filmes-favoritos.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.
-844 Bytes
Binary file not shown.

romances-blake-crouch.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Romances Blake Crouch
2+
3+
Abandon (July 7, 2009)
4+
Famous (April 15, 2010)
5+
Snowbound (June 22, 2010)
6+
Run (February 24, 2011)
7+
Eerie (with Jordan Crouch (June 7, 2012)
8+
Dark Matter (July 26, 2016)
9+
Good Behavior (November 15, 2016)
10+
Recursion (June 11, 2019)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package br.com.dio.exceptions;
2+
3+
import javax.swing.*;
4+
import java.io.*;
5+
6+
//Imprimir um arquivo no console.
7+
public class CheckedException {
8+
/*public static void main(String[] args) {
9+
String nomeDoArquivo = JOptionPane.showInputDialog("Nome do arquivo a ser exibido: ");
10+
imprimirArquivoNoConsole(nomeDoArquivo);
11+
12+
System.out.println("Apesar da exception ou não, o programa continua...");
13+
}
14+
15+
public static void imprimirArquivoNoConsole(String nomeDoArquivo) {
16+
File file = new File(nomeDoArquivo);
17+
18+
BufferedReader br = new BufferedReader(new FileReader(file.getName()));
19+
String line = br.readLine();
20+
21+
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
22+
23+
do{
24+
bw.write(line);
25+
bw.newLine();
26+
line=br.readLine();
27+
} while(line != null);
28+
bw.flush();
29+
br.close();
30+
}*/
31+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package br.com.dio.exceptions;
2+
3+
import javax.swing.*;
4+
import java.io.*;
5+
6+
public class ExceptionCustomizada_1 {
7+
public static void main(String[] args) {
8+
9+
String nomeDoArquivo = JOptionPane.showInputDialog("Nome do arquivo a ser exibido: ");
10+
imprimeArquivoNoConsole(nomeDoArquivo);
11+
System.out.println("Vai chegar nessa linha independente de qualquer coisa!");
12+
}
13+
14+
private static void imprimeArquivoNoConsole(String nomeDoArquivo) {
15+
File file = new File(nomeDoArquivo);
16+
try(BufferedReader br = new BufferedReader(new FileReader(file.getName()))) {
17+
String line = br.readLine();
18+
19+
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
20+
21+
do{
22+
bw.write(line);
23+
bw.newLine();
24+
line=br.readLine();
25+
} while(line != null);
26+
bw.flush();
27+
} catch (FileNotFoundException e) {
28+
JOptionPane.showMessageDialog(null, "Arquivo não existe: " + e.getMessage());
29+
e.printStackTrace();
30+
} catch (IOException e) {
31+
e.printStackTrace();
32+
}
33+
}
34+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package br.com.dio.exceptions;
2+
3+
public class ExceptionCustomizada_2 {
4+
public static void main(String[] args) {
5+
int[] numerador = {4, 2, 5, 8, 10};
6+
int[] denominador = {2, 0, 4, 0, 2, 8};
7+
8+
for(int i = 0; i < denominador.length; i++) {
9+
int resultado = numerador[i] / denominador[i];
10+
System.out.println(resultado);
11+
12+
}
13+
}
14+
15+
}
16+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package br.com.dio.exceptions;
2+
3+
import javax.swing.*;
4+
5+
//Fazer a divisão de 2 valores inteiros
6+
public class UncheckedException {
7+
public static void main(String[] args) {
8+
String a = JOptionPane.showInputDialog("Numerador: ");
9+
String b = JOptionPane.showInputDialog("Denominador: ");
10+
11+
int resultado = dividir(Integer.parseInt(a), Integer.parseInt(b));
12+
System.out.println("Resultado: " + resultado);
13+
}
14+
15+
public static int dividir(int a, int b) {
16+
return a / b;
17+
}
18+
}

src/br/com/dio/exemplos/Exemplo_1.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/br/com/dio/exemplos/Exemplo_2.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)