java读取pgm图片
程序员文章站
2022-03-19 23:37:39
...
java读取pgm图片
public static void main(String[] args) throws IOException {
String fileIn="src\\images\\16x16.pgm";//文件名
FileInputStream fileInputStream = new FileInputStream(fileIn);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream));
bufferedReader.readLine();//p5
bufferedReader.readLine();//长x宽
bufferedReader.readLine();//最大像素点
String str=new String(bufferedReader.readLine());//包含所有像素点信息的一维数组
}