Estou com um problema para criar uma caixa de diálogo…
O problema está na hora que especifico o tipo de mensagem (WARNING_MESSAGE e INFORMATION_MESSAGE), mas por que acontece isso? Não é uma variável estática.
Os erros encontram-se nas linhas 22 e 61…
Se puder ajudar ficarei grato…
import java.io.*;
import javax.swing.*;
public class QuebraArquivo {
public static String formata(int x) {
String base = "teste_parte_";
String ext = ".part";
if(x < 10) return base + "00" + x + ext;
else if(x < 100) return base + "0" + x + ext;
return base + x + ext;
}
public static void main(String[] args){
FileInputStream in = null;
boolean existeArquivo = true;
try {
in = new FileInputStream("teste.exe");
}
catch(FileNotFoundException e) {
existeArquivo = false;
JOptionPane.showMessageDialog(null, "Arquivo não encontrado.", "Erro", WARNING_MESSAGE);
}
try {
if(existeArquivo) {
FileOutputStream out = null;
int c = 0;
int contArq = 1;
int contBytes = 0;
String input = JOptionPane.showInputDialog(
"Tamanho limite dos arquivos particionados (em kb)");
int limite = Integer.parseInt(input) * 1024;
while(c != -1) {
if(contBytes == 0) out = new FileOutputStream(formata(contArq));
c = in.read();
if(c != -1) {
out.write(c);
contBytes++;
}
if(contBytes == limite) {
contBytes = 0;
contArq++;
out.close();
}
}
if(contBytes != 0) {
out.close();
}
in.close();
}
}
catch(FileNotFoundException e) {
e.printStackTrace();
}
catch(IOException e) {
e.printStackTrace();
}
JOptionPane.showMessageDialog(null, "Arquivo particionado.", "Concluído", INFORMATION_MESSAGE);
}
}