Pessoal
Tenho o seguinte conteudo de arquivo (text.txt):
#PER_CUSTOMER
1.111123
1.123114
1.78912387
2.123987167
3.12345678
4.333.1
1.698
100.28
1.10000
1.2324454
Como eu faço pra checar a primeira linha se ela for igual a “#PER_CUSTOMER” ela deve pegar as linhas abaixo (os numeros). Nao poderia pegar as linhas em branco.
package abrirarquivo;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws FileNotFoundException, IOException {
// TODO code application logic here
String arquivo = "C:/rob.txt";
File file = new File(arquivo);
if (! file.exists()) {
System.out.println("ERROR");
}
BufferedReader br = new BufferedReader(new FileReader(arquivo));
StringBuffer bufSaida = new StringBuffer();
String linha;
while( (linha = br.readLine()) != null ){
if(!linha.trim().equals(FileType.CUSTOMER.getDescription()))
bufSaida.append(linha).append("\n");
}
br.close();
System.out.println(bufSaida);
}
}
package abrirarquivo;
public enum FileType {
CUSTOMER(1,"#PER_CUSTOMER"),
RATE_PLAN(2,"#PER_RATE_PLAN"),
COST_CENTER(3,"#PER_COST_CENTER"),
CUSTOMER_TYPE(4,"#PER_CUSTOMER_TYPE")
;
private Integer id;
private String description;
private FileType(Integer id, String description) {
this.id = id;
this.description = description;
}
private Integer toInteger(){
return this.id;
}
public static FileType valueOf(Integer id){
FileType status = null;
if (id!=null){
for (FileType obj : FileType.values()) {
if (obj.toInteger().equals(id)) {
status = obj;
break;
}
}
}
return status;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
