Boa tarde,amigos.
Como eu posso alinhar a esquerda códigos desse arquivo.
OBS. a separação do código para a data tem que ser um espaço em branco.
Comentário: è uma penintencia alinhar esses aquivos de exemplo como eu gostaria. perdi a paciência :(
[list]
Arquivo hoje:
106 2008-03-25 08:00:0
106 2008-03-25 11:50:0
106 2008-03-25 14:50:0
106 2008-03-25 17:50:0 * Os códigos fican alinhados a direita tipo (Inteiros)
1089 2008-03-25 07:50:
1089 2008-03-25 11:50:
1089 2008-03-25 14:50:
1089 2008-03-25 17:50:
Arquivo depois do alinhamento:
106 2008-03-25 08:00:0 106 2008-03-25 11:50:0 106 2008-03-25 14:50:0 106 2008-03-25 17:50:0 1089 2008-03-25 07:50: *Os código ficam alinhados a esqueda tipo (String) 1089 2008-03-25 11:50: 1089 2008-03-25 14:50: 1089 2008-03-25 17:50: [/list]private void buttonGerarArquivoMouseClicked(java.awt.event.MouseEvent evt) {
try{
BufferedReader input = new BufferedReader(new FileReader("C:\\Gerador\\HORA300.txt"));
try{
String line = null;
FileWriter arquivo;
PrintWriter escrever;
arquivo = new FileWriter("C:\\Gerador\\MODELO.txt");
escrever = new PrintWriter(arquivo);
line = input.readLine();
String documento = "";
while (line != null){
documento = documento + line.substring(0,22);
documento = documento + "\n";
line = input.readLine();
}
escrever.append(documento.replaceAll("\t"," "));
escrever.close();
}catch(java.io.IOException ioex){
}finally{
input.close();
}
}catch (IOException ioe){
}
try {
BufferedReader entrada = new BufferedReader(new FileReader("C:\\Gerador\\MODELO.txt"));
try{
String strCodigo = "";
String strData = "";
String strHora = "";
String linha = null;
File arquivo2;
PrintWriter escrever2;
arquivo2 = new File("C:\\Gerador\\HORASAF.txt");
escrever2 = new PrintWriter(arquivo2);
Scanner scanner = new Scanner(entrada);
while (scanner.hasNext()){
int numero = Integer.parseInt(scanner.next());
strCodigo = String.format("%4s",numero);
strData = scanner.next();
strHora = scanner.next();
escrever2.append(strCodigo+ " "+strData+" "+strHora+"\n");
}
escrever2.close();
JOptionPane.showMessageDialog(null,"Arquivo gerado!");
this.dispose();
}catch(IOException ioex){
ioex.printStackTrace();
}
}catch(IOException ioex){
ioex.printStackTrace();
}
}