FileNameExtensionFilter filtro = new FileNameExtensionFilter("*.jpg", "jpg");
chooser.setFileFilter(filtro);
int resposta = chooser.showOpenDialog(new JDialog());
File file = new File("");
if(resposta == JFileChooser.APPROVE_OPTION){
file = chooser.getSelectedFile();
String foto = file.getPath();
Foto.setText(foto);
}else if(resposta == JFileChooser.CANCEL_OPTION){
}
Por equanto fiz isso num botão
public byte[] read(File file) throws IOException, FileTooBigException {
if (file.length() > MAX_FILE_SIZE) {
throw new FileTooBigException(file);
}
byte[] buffer = new byte[(int) file.length()]; InputStream ios = null; try { ios = new FileInputStream(file); if (ios.read(buffer) == -1) { throw new IOException( "EOF reached while trying to read the whole file"); } } finally { try { if (ios != null) ios.close(); } catch (IOException e) { } } return buffer; }
e ai com o byte[] voce cria um campo do tipo bytea/blob no banco ai depende de cada banco de dados
Obrigado. Só uma duvida, a parte do ios serve pra que?