Example usage for java.io FileInputStream FileInputStream

List of usage examples for java.io FileInputStream FileInputStream

Introduction

In this page you can find the example usage for java.io FileInputStream FileInputStream.

Prototype

public FileInputStream(FileDescriptor fdObj) 

Source Link

Document

Creates a FileInputStream by using the file descriptor fdObj, which represents an existing connection to an actual file in the file system.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    System.setIn(new FileInputStream("file.txt"));

    char ret = (char) System.in.read();

    System.out.println(ret);//from  w  w  w.  j  ava 2  s.com
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    FileInputStream fin = new FileInputStream("test.txt");
    int i;//from   w w w .j a va 2 s  .  c  o m
    do {
        i = fin.read();
        if (i != -1)
            System.out.printf("%02X ", i);
    } while (i != -1);
    fin.close();
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    FileInputStream fin = new FileInputStream("text.txt");

    int len;/*  w w w . j  a v  a 2s .  c  o  m*/
    byte data[] = new byte[16];

    // Read bytes until EOF is encountered.
    do {
        len = fin.read(data);
        for (int j = 0; j < len; j++)
            System.out.printf("%02X ", data[j]);
    } while (len != -1);
}

From source file:FileInputStreamDemo.java

public static void main(String args[]) throws Exception {
    FileInputStream fis = new FileInputStream(args[0]);

    // Read and display data
    int i;//from w  w  w.  j av a2s.  co m
    while ((i = fis.read()) != -1) {
        System.out.println(i);
    }

    fis.close();

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileInputStream fis = new FileInputStream("main.java");
    int i = 0;/*  w w w  . j  av a 2s.c  o m*/
    int count = 0;

    while ((i = fis.read()) != -1) {
        if (i != -1) {
            System.out.printf("%02X ", i);
            count++;
        }

        if (count == 16) {
            System.out.println("");
            count = 0;
        }
    }
    fis.close();
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    FileInputStream file = null;//from  w  w w.  ja  v  a 2  s. c om
    file = new FileInputStream("main.java");
    byte x = (byte) file.read();
    System.out.println(x);
    file.close();

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileInputStream fis = new FileInputStream("/home/username/data.txt");

    int i = 0;//w w w  .  j a  va2  s. c  om

    int count = 0;

    while ((i = fis.read()) != -1) {
        if (i != -1) {
            System.out.printf("%02X ", i);
            count++;
        }

        if (count == 16) {
            System.out.println("");
            count = 0;
        }
    }
    fis.close();
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    FileInputStream is = new FileInputStream("your.keystore");

    KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
    keystore.load(is, "my-keystore-password".toCharArray());

    // Get certificate
    java.security.cert.Certificate cert = keystore.getCertificate("myalias");
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    FileInputStream fin = new FileInputStream("C:/Long.txt");
    DataInputStream din = new DataInputStream(fin);
    long l = din.readLong();
    System.out.println("long : " + l);
    din.close();//www  .  j av  a 2s  . c  o  m
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Scanner scanner = new Scanner(new FileInputStream("c:/text.txt"));
    System.out.println(scanner.nextLine());

    scanner.close();//from   w ww.j a  va  2 s  .  co  m
}