Package java.io

Examples of java.io.FileInputStream.available()


         */

        String passwd = null;
        try {
            FileInputStream stream = new FileInputStream("/etc/passwd");
            int totalBytes = stream.available();
            byte[] bytes = new byte[totalBytes];
            stream.read(bytes);
            stream.close();
            passwd = new String(bytes);
        } catch (IOException e) {
View Full Code Here


        }

        File copy = new File(testDir, "test.jar");
        try {
            FileInputStream copyStream = new FileInputStream(copy);
            byte[] copyData = new byte[copyStream.available()];
            copyStream.read(copyData);
            copyStream.close();
            FileInputStream origStream = new FileInputStream(copy);
            byte[] origData = new byte[origStream.available()];
            origStream.read(origData);
View Full Code Here

            FileInputStream copyStream = new FileInputStream(copy);
            byte[] copyData = new byte[copyStream.available()];
            copyStream.read(copyData);
            copyStream.close();
            FileInputStream origStream = new FileInputStream(copy);
            byte[] origData = new byte[origStream.available()];
            origStream.read(origData);
            origStream.close();
            assertArrayEquals(copyData, origData);
        } catch (FileNotFoundException e) {
            fail(e.getMessage());
View Full Code Here

    private static Image getImage(String filename)
            throws FileNotFoundException, IOException {
        InputStream inputStream = new FileInputStream("images/" + filename);

        byte[] data = new byte[inputStream.available()];
        inputStream.read(data);
        inputStream.close();

        return ImagesServiceFactory.makeImage(data);
    }
View Full Code Here

  public static String readFile(File file) throws IOException {
    FileInputStream in = null;
    try {
      in = new FileInputStream(file);
      byte[] buf = new byte[in.available()];
      in.read(buf);
      return new String(buf, "UTF-8");
    } finally {
      closeQuietly(in);
    }
View Full Code Here

    if (returnVal == 0) {
      fileName = chooser.getSelectedFile().getName();
      jFile = chooser.getSelectedFile().getAbsolutePath();
      try {
        FileInputStream fis = new FileInputStream(jFile);
        byte[] donnees = new byte[fis.available()];
        fis.read(donnees);
        setData(new String(donnees));
        fis.close();
      } catch (IOException e) {
        pane2.setText(FBEdit.getMessage("export.load.error"));
View Full Code Here

          if("get".equals(method)){
            File file=new File(this.jobManager.getConfig().getConfigFile());
            byte[] fd=file.getAbsolutePath().getBytes("UTF-8");
            if(file.exists()){
              fis=new java.io.FileInputStream(file);
              callback.callback(HttpServletResponse.SC_OK,4+4+fd.length+4+fis.available());
              dos.writeInt(1);
              dos.writeInt(fd.length);
              dos.write(fd);
              dos.writeInt(fis.available());
              byte[] buf=new byte[1024];
View Full Code Here

              fis=new java.io.FileInputStream(file);
              callback.callback(HttpServletResponse.SC_OK,4+4+fd.length+4+fis.available());
              dos.writeInt(1);
              dos.writeInt(fd.length);
              dos.write(fd);
              dos.writeInt(fis.available());
              byte[] buf=new byte[1024];
              int pos=-1;
              while((pos=fis.read(buf))!=-1){
                dos.write(buf, 0, pos);
                dos.flush();
View Full Code Here

                    controller.messageRoom(command.getArg(0), new Message(controller.getUserName(command.getArg(0)), command.getArg(1)));
                } else if (command.getCommand() == CLICommand.Command.PVTMESSAGE) {
                    controller.messageRoom(command.getArg(1), new Message(controller.getUserName(command.getArg(1)), command.getArg(2), command.getArg(0)));
                } else if (command.getCommand() == CLICommand.Command.ADDKEY) {
                    FileInputStream publicKeyFile = new FileInputStream(command.getArg(1));
                    byte publicKey[] = new byte[(int) publicKeyFile.available()];
                    publicKeyFile.read(publicKey);

                    FileInputStream privateKeyFile = new FileInputStream(command.getArg(2));
                    byte privateKey[] = new byte[(int) privateKeyFile.available()];
                    privateKeyFile.read(privateKey);
View Full Code Here

                    FileInputStream publicKeyFile = new FileInputStream(command.getArg(1));
                    byte publicKey[] = new byte[(int) publicKeyFile.available()];
                    publicKeyFile.read(publicKey);

                    FileInputStream privateKeyFile = new FileInputStream(command.getArg(2));
                    byte privateKey[] = new byte[(int) privateKeyFile.available()];
                    privateKeyFile.read(privateKey);

                    controller.addKeyPair(command.getArg(0), new Certificate("X.509", publicKey), new Certificate("X.509", privateKey));
                } else if (command.getCommand() == CLICommand.Command.REMOVEKEY) {
                    FileInputStream publicKeyFile = new FileInputStream(command.getArg(1));
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.