import java.util.Scanner;
import <a href="http://java.io">java.io</a>.*;
import javax.swing.JOptionPane;
public class Exercicio1 {
public static void main (String []args) {
Scanner input = new Scanner (System.in);
int num;
JOptionPane.showInputDialog("Digite o nome do arquivo: ");
try {
String FileName = input.next();
input = new Scanner (new File(FileName));
while (input.hasNext()) {
num = input.nextInt();
String by = Integer.toBinaryString(num);
if (num == 0) break;
JOptionPane.showMessageDialog(null,“A conversão dos números contidos no arquivo é:” + by);
}
}
catch (FileNotFoundException e) {
System.out.println(“Arquivo não existente.”);
}
catch (InputMismatchException e) {
System.out.println(“Valor lido não é inteiro válido.”);
}
}
}