private Jp2File getOpenJ2pFile(File outputFile) throws IOException { Jp2File jp2File = openFiles.get(outputFile); if (jp2File == null) { jp2File = new Jp2File(); jp2File.file = outputFile; jp2File.stream = new FileImageInputStream(outputFile); jp2File.header = jp2File.stream.readLine(); jp2File.dataPos = jp2File.stream.getStreamPosition(); final String[] tokens = jp2File.header.split(" "); if (tokens.length != 6) { throw new IOException("Unexpected tile format"); } // String pg = tokens[0]; // PG // String ml = tokens[1]; // ML // String plus = tokens[2]; // + int jp2Width; int jp2Height; try { // int jp2File.nbits = Integer.parseInt(tokens[3]); jp2File.width = Integer.parseInt(tokens[4]); jp2File.height = Integer.parseInt(tokens[5]); } catch (NumberFormatException e) { throw new IOException("Unexpected tile format"); } openFiles.put(outputFile, jp2File); } return jp2File; }