Txt para xls com split

0 respostas
V

oi pessoal, criei um metodo fatiador, um metodo leitor() e um metodo salvar
o metodo ler() é chamado dentro de salvar()
e o metodo part() fatia a String content que tambem está em salvar()

o que ocorre é que se cria o arquivo xls porém o arquivo txt chamado("paulo;pinto;ferreira")
nao é fatiado em celulas diferentes, pior: da null!!

peço ajuda

grande abraço

import java.awt.Font;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JFileChooser;


public class C1{
	
	File f;
	String ler;
	
	
	//METODO FATIADOR
	public String part(String a){
		String[]b = a.split(";");
			for(int x =0;x <=4; x++){
				System.out.println(b[x].toString());
			}
			return a;	
	}
	
	
	
	//LE ARQUIVO TXT
	public String ler(){
		JFileChooser choo = new JFileChooser();
		int res = choo.showOpenDialog(choo);
			if(res == JFileChooser.APPROVE_OPTION){
			   f = choo.getSelectedFile();
			}
			try{ 
				BufferedReader l = new BufferedReader(new FileReader(f));
					while(l.readLine() != null){
						ler = l.readLine();
						System.out.println(ler);
					}
			}
			catch(Exception e){
				e.printStackTrace();
		    }
			return ler;
    }
	
	
	
	
	 
	 //SALVA EM ARQUIVO XLS
	 public void salvar(){
		 String l = ler();
		 
		 JFileChooser choo = new JFileChooser();

		 int res = choo.showSaveDialog(choo);
		 if(res == JFileChooser.APPROVE_OPTION){
			 f = choo.getSelectedFile();
             
             String novo = f.getAbsolutePath().concat(".xls");
             String content = part(l); // USANDO METODO FATIADOR
             File fileN  = new File(novo);
	             try{
	             FileWriter ff = new FileWriter(fileN);
	             ff.append(content);
	             ff.close();
	             }
	             catch(IOException e){} 
         }
		 
		 
	 }

	public static void main(String[] args){  
		    C1 C = new C1();
		    C.salvar();
	}
}
Criado 10 de junho de 2010
Respostas 0
Participantes 1