/src/main/java/com/levigo/jbig2/io/DefaultInputStreamFactory.java

http://jbig2-imageio.googlecode.com/ · Java · 42 lines · 15 code · 6 blank · 21 comment · 0 complexity · f6abbb48d034fb72a82a23e85e979aae MD5 · raw file

  1. /**
  2. * Copyright (C) 1995-2014 levigo holding gmbh.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. package com.levigo.jbig2.io;
  18. import java.io.IOException;
  19. import java.io.InputStream;
  20. import javax.imageio.stream.FileCacheImageInputStream;
  21. import javax.imageio.stream.ImageInputStream;
  22. import javax.imageio.stream.MemoryCacheImageInputStream;
  23. /**
  24. *
  25. * @author <a href="mailto:m.krzikalla@levigo.de">Matth채us Krzikalla</a>
  26. * @author Benjamin Zindel
  27. */
  28. public class DefaultInputStreamFactory implements InputStreamFactory {
  29. public ImageInputStream getInputStream(InputStream is) {
  30. try {
  31. return new FileCacheImageInputStream(is, null);
  32. } catch (IOException e) {
  33. return new MemoryCacheImageInputStream(is);
  34. }
  35. }
  36. }