MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / AsciiInput

Class AsciiInput

src/main/java/trace/graphics/PlyReader.java:769–798  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

767 }
768 return new Pair(vertices, triangles);
769 }
770
771 interface Input extends Closeable {
772 public Number read(Type type) throws IOException;
773 public void needEnd() throws IOException;
774 }
775 private static class AsciiInput implements Input {
776 private final Scanner scanner;
777
778 public AsciiInput(InputStream in) throws IOException {
779 scanner = new Scanner(new BufferedInputStream(in), "US-ASCII");
780
781 // skip the header
782 String line;
783 do {
784 line=scanner.nextLine();
785 } while (!"end_header".equals(line));
786 }
787
788 @Override
789 public Number read(Type type) throws IOException {
790 return type.parse(scanner);
791 }
792
793 @Override
794 public void needEnd() throws IOException {
795 if (scanner.hasNext())
796 throw new InvalidPlyFormatException("Invalid file format: expected end of file, found "+scanner.next());
797 }
798
799 @Override
800 public void close() throws IOException {
801 scanner.close();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected