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:MainClass.java

public static void main(String args[]) throws Exception {
    Properties p = new Properties();
    p.load(new FileInputStream("colon.txt"));
    p.list(System.out);/*w w  w .  java2s.  c  om*/
}

From source file:Main.java

public static void main(String[] args) throws Exception {

    // new input stream created
    InputStream is = new FileInputStream("C://test.txt");

    // returns true if the mark()/reset() supported.
    boolean bool = is.markSupported();
    is.close();/*from  ww w  .  ja v a2 s  . c o m*/
    System.out.print(bool);

}

From source file:Main.java

public static void main(String[] a) {
    FileInputStream inputFile = null;
    try {/*w w w . j a va  2s . com*/
        inputFile = new FileInputStream("C:/myFile.txt");
    } catch (FileNotFoundException e) {
        e.printStackTrace(System.err);
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    File file = new File("C:/String.txt");
    FileInputStream fin = new FileInputStream(file);

    byte fileContent[] = new byte[(int) file.length()];
    fin.read(fileContent);//from w ww  . j ava  2s. co m
    System.out.println(new String(fileContent));
}

From source file:Main.java

public static void main(String[] args) throws IOException {
    FileInputStream fis = new FileInputStream("C://test.txt");

    // get file descriptor
    FileDescriptor fd = fis.getFD();

    // tests if the file is valid
    boolean bool = fd.valid();

    System.out.println("Valid file: " + bool);

}

From source file:MainClass.java

public static void main(String[] args) throws Exception {
    FileChannel in = new FileInputStream("source.txt").getChannel(),
            out = new FileOutputStream("target.txt").getChannel();
    in.transferTo(0, in.size(), out);/*w  w w . j  a v a2  s . c  o m*/
    // Or:
    // out.transferFrom(in, 0, in.size());
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    Properties prop = new Properties();
    FileInputStream fis = new FileInputStream("sampleprops.xml");
    prop.loadFromXML(fis);/*w  w  w.j a va  2s . c o m*/
    prop.list(System.out);
    System.out.println("\nThe foo property: " + prop.getProperty("foo"));
}

From source file:Main.java

public static void main(String[] args) throws IOException {
    FileInputStream fis = new FileInputStream(FileDescriptor.in);

    // skip bytes from file input stream
    fis.skip(4);/*from w  ww.  j a  v  a 2  s  .  com*/

    // read bytes from this stream
    int i = fis.read();

    // converts integer to character
    char c = (char) i;
    System.out.print("Character read: " + c);
}

From source file:Main.java

public static void main(String[] args) throws IOException {

    int i = 0;//from w  w w.j a v a2s .c o m

    FileInputStream fis = new FileInputStream("C://test.txt");

    // read till the end of the stream
    while ((i = fis.read()) != -1) {
        // available bytes
        int available = fis.available();

        // convert integer to character
        char c = (char) i;

        System.out.println("Available: " + available);
        System.out.println("Read: " + c);
    }

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    FileChannel srcChannel = new FileInputStream("srcFilename").getChannel();
    FileChannel dstChannel = new FileOutputStream("dstFilename").getChannel();

    dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
    srcChannel.close();/*from   w w  w. jav  a2 s  . c  o m*/
    dstChannel.close();
}