Examples of FileInputStream


Examples of com.zaranux.client.java.io.FileInputStream

  //    return terminalEditor.getWidget();
  //  }
   
    public Terminal()
    {
      FileInputStream fdIn = new FileInputStream(FileDescriptor.in);
      fdIn.setInputBuffer(inBuffer);
      in = fdIn; //new BufferedInputStream(fdIn);
       
      FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
      fdOut.setOutputBuffer(outBuffer);
      //out = new PrintStream(new BufferedOutputStream(fdOut, 128), true);
View Full Code Here

Examples of de.schlichtherle.io.FileInputStream

        }
        return false;
    }
   
    public static byte[] readFile(File file) throws IOException {
        InputStream in = new FileInputStream(file);
        try {
            return IOUtils.toByteArray(in);
        } finally {
            in.close();
        }
    }
View Full Code Here

Examples of java.io.FileInputStream

  static void loadConnectionProperties() {
    if (p != null) {
      return;
    }
      Properties props = new Properties();
      FileInputStream fis = null;
      try {
        fis = new FileInputStream("connection.properties"); //$NON-NLS-1$
        props.load(fis);
      } catch (IOException e) {
        log.log(Level.WARNING, "Could not load default connection properties.", e); //$NON-NLS-1$
      } finally {
        if (fis != null) {
          try {
          fis.close();
        } catch (IOException e) {
        }
        }
      }     
      p = props;
View Full Code Here

Examples of java.io.FileInputStream

 
  @Doc(text = "Deploy a VDB from file")
  public static void deployVDB(
      @Doc(text = "file name") String vdbFile) throws AdminException, FileNotFoundException {
    File file = new File(vdbFile);
    FileInputStream fis = new FileInputStream(file);
    try {
      getAdmin().deployVDB(file.getName(), fis);
    } finally {
      try {
        fis.close();
      } catch (IOException e) {
      }
    }
  }
View Full Code Here

Examples of java.io.FileInputStream

      response.setContentType(mimeType);
     
      if (possibleCached.exists()) {
        // send content
        byte[] buffer = new byte[(int) possibleCached.length()];
        FileInputStream fis = new FileInputStream(possibleCached);
        fis.read(buffer);
        fis.close();
        response.getOutputStream().write(buffer);
        response.getOutputStream().flush();
        response.getOutputStream().close();
      } else {

        BufferedImage image = ImageIO.read(tfile);

        BufferedImage myImage =
          new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
        Graphics g = myImage.getGraphics();
        g.setColor(Color.WHITE);
        g.fillRect(0, 0, w, h);

        int width = image.getWidth();
        int height = image.getHeight();

        if (width > height) {
          Image newImage =
            image.getScaledInstance(w, -1, Image.SCALE_SMOOTH);
          g.drawImage(
            newImage,
            0,
            (h - newImage.getHeight(null)) / 2,
            null);
        } else {
          Image newImage =
            image.getScaledInstance(-1, h, Image.SCALE_SMOOTH);
          g.drawImage(
            newImage,
            (w - newImage.getWidth(null)) / 2,
            0,
            null);
        }

        ImageIO.write(myImage, "jpg", possibleCached);
        ImageIO.write(myImage, "jpg", response.getOutputStream());
        response.getOutputStream().flush();
        response.getOutputStream().close();
      }

    } else {

      // retrieve mime type
      String mimeType =
        FileTypeMap.getDefaultFileTypeMap().getContentType(tfile);
      response.setContentType(mimeType);

      // send content
      byte[] buffer = new byte[(int) tfile.length()];
      FileInputStream fis = new FileInputStream(tfile);
      fis.read(buffer);
      fis.close();
      response.getOutputStream().write(buffer);
      response.getOutputStream().flush();
      response.getOutputStream().close();

    }
View Full Code Here

Examples of java.io.FileInputStream

        File dir = new File(root, bean.getDirectory());
        File[] files = dir.listFiles();
        for (int k = 0; k < files.length; k++) {
          File file = files[k];
          if (file.isFile()) {
            InputStream in = new FileInputStream(file);
            ZipEntry ze =
              new ZipEntry(
                "resources/"
                  + bean.getId()
                  + "/"
                  + file.getName());
            zip.putNextEntry(ze);

            // Transfer bytes from the file to the ZIP file
            int len;
            while ((len = in.read(buf)) > 0) {
              zip.write(buf, 0, len);
            }

            zip.closeEntry();
            in.close();
          }
        }
      }

      // add images
      File root =
        new File(getServletContext().getRealPath("/"), imagesPath);
      File[] files = root.listFiles();
      for (int k = 0; k < files.length; k++) {
        File file = files[k];
        if (file.isFile()) {
          InputStream in = new FileInputStream(file);
          ZipEntry ze = new ZipEntry("images/" + file.getName());
          zip.putNextEntry(ze);

          // Transfer bytes from the file to the ZIP file
          int len;
          while ((len = in.read(buf)) > 0) {
            zip.write(buf, 0, len);
          }

          zip.closeEntry();
          in.close();
        }
      }

      // add sections
      Mapping.begin();
View Full Code Here

Examples of java.io.FileInputStream

  private static ResourceXmlBean bean;
 
  public static ResourceXmlBean getResourceXmlBean(HttpServlet servlet, String id) throws Exception {
    if( bean == null ) {
      FileInputStream fis = new FileInputStream( new File(servlet.getServletContext().getRealPath("../../../conf/resources.xml")) );
      bean = ResourceXmlBean.parse(fis);
      fis.close();
    }
    return bean.getResource(id);
  }
View Full Code Here

Examples of java.io.FileInputStream

    return bean.getResource(id);
  }
 
  public static Vector getResourceXmlBeans(HttpServlet servlet) throws Exception {
    if( bean == null ) {
      FileInputStream fis = new FileInputStream( new File(servlet.getServletContext().getRealPath("../../../conf/resources.xml")) );
      bean = ResourceXmlBean.parse(fis);
      fis.close();
    }
    return bean.getItems();
  }
View Full Code Here

Examples of java.io.FileInputStream

  private static TypeBean bean;
 
  public static TypeBean getSectionBean(HttpServlet servlet, String template) throws Exception {
    if( bean == null ) {
      FileInputStream fis = new FileInputStream( new File(servlet.getServletContext().getRealPath("../../../conf/templates.xml")) );
      bean = TypeBean.parse(fis);
      fis.close();
    }
    return bean.getBean(template);
  }
View Full Code Here

Examples of java.io.FileInputStream

    return bean.getBean(template);
  }
 
  public static Vector getSectionsBeans(HttpServlet servlet) throws Exception {
    if( bean == null ) {
      FileInputStream fis = new FileInputStream( new File(servlet.getServletContext().getRealPath("../../../conf/templates.xml")) );
      bean = TypeBean.parse(fis);
      fis.close();
    }
    return bean.getItems();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.