List of usage examples for java.io FileInputStream FileInputStream
public FileInputStream(FileDescriptor fdObj)
FileInputStream
by using the file descriptor fdObj
, which represents an existing connection to an actual file in the file system. From source file:Main.java
public static void main(String[] args) throws Exception { FileInputStream fin = new FileInputStream("C:/Array.txt"); DataInputStream din = new DataInputStream(fin); byte b[] = new byte[10]; din.read(b);/*from w w w . ja va 2 s .co m*/ din.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { FileInputStream fin = new FileInputStream("C:/Short.txt"); DataInputStream din = new DataInputStream(fin); short s = din.readShort(); System.out.println("short : " + s); din.close();/*from w w w . jav a 2s. c om*/ }
From source file:Main.java
public static void main(String[] args) throws Exception { FileInputStream fin = new FileInputStream("C:/UnsignedByte.txt"); DataInputStream din = new DataInputStream(fin); int i = din.readUnsignedByte(); System.out.println("Unsinged byte value : " + i); din.close();/*from w ww.j a va2s. c om*/ }
From source file:Main.java
public static void main(String[] args) throws Exception { FileInputStream fin = new FileInputStream("C:/Float.txt"); DataInputStream din = new DataInputStream(fin); float f = din.readFloat(); System.out.println("float : " + f); din.close();/* ww w .j a v a 2 s . c om*/ }
From source file:Main.java
public static void main(String[] args) throws IOException { FileInputStream fis = new FileInputStream("C://test.txt"); // skip bytes from file input stream fis.skip(4);/*w w w . jav a2s.co m*/ // 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 { FileInputStream fis = new FileInputStream("C://test.txt"); int i = fis.read(); char c = (char) i; System.out.println(c);// w ww .ja v a 2 s . c om // close file input stream fis.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { FileInputStream fileIn = new FileInputStream("data.txt"); DataInputStream dataIn = new DataInputStream(fileIn); System.out.println(dataIn.readUTF()); int counter = dataIn.readInt(); double sum = 0.0; for (int i = 0; i < counter; i++) { double current = dataIn.readDouble(); System.out.println("Just read " + current); sum += current;/* w w w.j a v a 2 s . c o m*/ } System.out.println("\nAverage = " + sum / counter); dataIn.close(); fileIn.close(); }
From source file:Load.java
public static void main(String args[]) throws Exception { Properties p = new Properties(); p.load(new FileInputStream("colon.txt")); p.getProperty("foo"); }
From source file:Main.java
public static void main(String[] args) throws Exception { InputStream is = new FileInputStream("C://test.txt"); // read and print characters one by one System.out.println("Char : " + (char) is.read()); System.out.println("Char : " + (char) is.read()); System.out.println("Char : " + (char) is.read()); // mark is set on the input stream is.mark(0);/*from w w w . ja va 2 s.com*/ System.out.println("Char : " + (char) is.read()); System.out.println("Char : " + (char) is.read()); if (is.markSupported()) { // reset invoked if mark() is supported is.reset(); System.out.println("Char : " + (char) is.read()); System.out.println("Char : " + (char) is.read()); } is.close(); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { Properties p = new Properties(); p.load(new FileInputStream("test.txt")); p.list(System.out);/*from ww w. j a v a2 s.c o m*/ }