Olá pessoal,
Estou precisando carregar um arquivo .PMG mas estou tendo problemas.
O começo do arquivo contém os seguintes valores nessa ordem
P2//
256 256//
255//
60 192 184 188 188 200 192 200 192 200 196 192 188 184 172 172 160 168 164 164 168 168 172 172 168 164 164 164 160 160 160 160 156 160 164 172 172 176 176 172 164 172
Eu preciso de 4 variáveis para pegar cada um desses 4 primeiros valores(Estão com duas barras).
O problema é que uma das variáveis estã pegando os dois valores(256 256) e não apenas um.
Como fazer isso?
public class TesteLeituraPmg {
public static void main(String args[]) throws IOException{
FileInputStream fileInputStream = new FileInputStream("imagem.pgm");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream));
String numeroMagico = "";
String largura = "";
String altura = "";
String maximoValorDeBrilho = "";
int cont=0;
String str = "";
while (bufferedReader.ready()) {
str = bufferedReader.readLine();
if(cont==0){
numeroMagico = str;
}
else if(cont==1){
largura = str;
}
else if(cont==2){
maximoValorDeBrilho = str;
}
cont++;
}
bufferedReader.close();
System.out.println(numeroMagico);
System.out.println(largura);
System.out.println(maximoValorDeBrilho);
}
}