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 { String fontFileName = "yourfont.ttf"; InputStream is = new FileInputStream(fontFileName); Font ttfBase = Font.createFont(Font.TRUETYPE_FONT, is); Font ttfReal = ttfBase.deriveFont(Font.BOLD); }
From source file:Main.java
public static void main(String[] args) throws Exception { String fontFileName = "yourfont.ttf"; InputStream is = new FileInputStream(fontFileName); Font ttfBase = Font.createFont(Font.TRUETYPE_FONT, is); Font ttfReal = ttfBase.deriveFont(Font.PLAIN, 24); }
From source file:Main.java
public static void main(String[] args) throws IOException { FileInputStream fis = new FileInputStream("C:/test.txt"); LineNumberInputStream lnis = new LineNumberInputStream(fis); System.out.println((char) lnis.read()); System.out.println((char) lnis.read()); lnis.mark(0);// w w w . j a v a2 s. c o m System.out.println("mark() invoked"); System.out.println((char) lnis.read()); System.out.println((char) lnis.read()); if (lnis.markSupported()) { lnis.reset(); System.out.println("reset() invoked"); System.out.println((char) lnis.read()); System.out.println((char) lnis.read()); } }
From source file:Main.java
public static void main(String[] args) throws Exception { String fontFileName = "yourfont.ttf"; InputStream is = new FileInputStream(fontFileName); Font ttfBase = Font.createFont(Font.TRUETYPE_FONT, is); Font ttfReal = ttfBase.deriveFont(24F); }
From source file:Main.java
public static void main(String[] args) throws Exception { byte[] buffer = new byte[5]; InputStream is = new FileInputStream("C://test.txt"); System.out.println("Characters printed:"); // read stream data into buffer is.read(buffer, 2, 3);/*from w w w.j ava 2 s. com*/ // for each byte in the buffer for (byte b : buffer) { char c = ' '; // convert byte to character if (b == 0)// if b is empty c = '-'; else c = (char) b;// if b is read System.out.print(c); } is.close(); }
From source file:Main.java
public static void main(String[] args) throws IOException { FileInputStream fin = new FileInputStream("a.zip"); Checksum cs = new CRC32(); for (int b = fin.read(); b != -1; b = fin.read()) { cs.update(b);// ww w . j a v a 2s .c om } System.out.println(cs.getValue()); fin.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { FileInputStream fis = new FileInputStream(args[0]); ZipInputStream zis = new ZipInputStream(fis); ZipEntry ze;/*from ww w . ja v a2 s . c o m*/ while ((ze = zis.getNextEntry()) != null) System.out.println( ze.getName() + " [" + ze.getSize() + "] [" + new Date(ze.getTime()).toString() + "]"); }
From source file:Main.java
public static void main(String[] argv) throws Exception { CheckedInputStream cis = new CheckedInputStream(new FileInputStream("filename"), new Adler32()); byte[] tempBuf = new byte[128]; while (cis.read(tempBuf) >= 0) { }//from ww w . ja v a 2 s .c om long checksum = cis.getChecksum().getValue(); }
From source file:Main.java
public static void main(String[] args) throws Exception { int i;// w ww . j av a 2s . c om // new input stream created InputStream is = new FileInputStream("C://test.txt"); System.out.println("Characters printed:"); // reads till the end of the stream while ((i = is.read()) != -1) { // converts integer to character char c = (char) i; System.out.print(c); } is.close(); }
From source file:Main.java
public static void main(String[] args) throws IOException { int i;/*from w ww . j a va 2 s.c om*/ FileInputStream fis = new FileInputStream("C:/test.txt"); LineNumberInputStream lnis = new LineNumberInputStream(fis); while ((i = lnis.read()) != -1) { char c = (char) i; System.out.print(c); } }