Estou tentado fazer com que o códogo leia o arquivo e faça copia, mas ele somente lê arquivos txt. Como faço para que ele leia algum formato de banco de dados?? pode ser o access mesmo.
javax.swing.JFileChooser arquivo = new javax.swing.JFileChooser();
arquivo.setFileSelectionMode( javax.swing.JFileChooser.FILES_ONLY );
//arquivo.setFileSelectionMode( javax.swing.JFileChooser.FILES_ONLY );
int resultadoArq = arquivo.showSaveDialog( null );
if( resultadoArq == javax.swing.JFileChooser.CANCEL_OPTION)
return;
File arquivoNome = arquivo.getSelectedFile();
if( arquivoNome == null || arquivoNome.getName().equals(""))
javax.swing.JOptionPane.showMessageDialog( null, "Nome de Arquivo Inválido",
"Nome de Arquivo Inválido", javax.swing.JOptionPane.ERROR_MESSAGE );
else{
try{
RandomAccessFile file = new RandomAccessFile( arquivoNome,"rw" );
file.writeUTF(taEntrada.getText().trim());
file.close();
}catch(Exception e){
}
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
calcula();
}
void calcula(){
String auxString = "", capturaLetra = "", resultado = "";
int tamanhoString = 0;
int tipoM = 0;
int variacaoPixel = 0;
for(int j = 0; j < dados.size(); j++){
auxString = dados.get(j).toString();
tamanhoString = auxString.length();
for(int i = 0; i < tamanhoString; i++){
capturaLetra = auxString.substring( i , i+1 );
if(!capturaLetra.equals("") )
resultado += capturaLetra;
}
resultado +="\n";
}
}
private void bSairActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
private void bAbrirActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String line_str;
try{
javax.swing.JFileChooser arquivo = new javax.swing.JFileChooser();
if(arquivo.showOpenDialog(arquivo) == javax.swing.JFileChooser.APPROVE_OPTION){
File file = arquivo.getSelectedFile();
String textoEntrada = "";
java.io.FileInputStream isTwo = new java.io.FileInputStream( "" +file.getPath() );
java.io.DataInputStream dsTwo = new java.io.DataInputStream(isTwo);
dados.removeAllElements();
while((line_str = dsTwo.readLine()) != null){
dados.add( line_str + " " );
textoEntrada += line_str + "\n";
}
taEntrada.setText( textoEntrada );
dsTwo.close( );
}
}catch (java.io.IOException e) {
javax.swing.JOptionPane.showMessageDialog( null, "File error: " + e.toString() );
}
}
EDIT - Editei o título porque estava escrito "bando de dados", o que obviamente é um erro bobo de digitação, já que as teclas C e D estão bem perto uma da outra no teclado.