/plugins/Templates/tags/Templates-4.1.2/templates/IO.java

# · Java · 62 lines · 30 code · 5 blank · 27 comment · 4 complexity · 61d3ccbeea8a72a49b2a3e4a6bf43eec MD5 · raw file

  1. /*
  2. * IO.java
  3. * Copyright (c) 2002 Calvin Yu
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. package templates;
  20. import java.io.InputStream;
  21. import java.io.IOException;
  22. import java.io.OutputStream;
  23. import org.gjt.sp.util.Log;
  24. /**
  25. * IO utilities.
  26. */
  27. public class IO
  28. {
  29. /**
  30. * Close input stream.
  31. */
  32. public static void close(InputStream in)
  33. {
  34. if (in == null) {
  35. return;
  36. }
  37. try {
  38. in.close();
  39. } catch (IOException e) {
  40. Log.log(Log.ERROR, IO.class, e);
  41. }
  42. }
  43. /**
  44. * Close output stream.
  45. */
  46. public static void close(OutputStream out)
  47. {
  48. if (out == null) {
  49. return;
  50. }
  51. try {
  52. out.close();
  53. } catch (IOException e) {
  54. Log.log(Log.ERROR, IO.class, e);
  55. }
  56. }
  57. }