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:MainClass.java
public static void main(String args[]) throws Exception { Vector v = new Vector(3); v.add(new FileInputStream("/a/b")); v.add(new FileInputStream("yourfile.bar")); v.add(new FileInputStream("/yourfile.txt")); Enumeration e = v.elements(); SequenceInputStream sis = new SequenceInputStream(e); InputStreamReader isr = new InputStreamReader(sis); BufferedReader br = new BufferedReader(isr); String line;//from ww w . j a va 2s. c o m while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { String source = "s.txt"; String destination = "d.txt"; FileInputStream fis = new FileInputStream(source); FileOutputStream fos = new FileOutputStream(destination); FileChannel fci = fis.getChannel(); FileChannel fco = fos.getChannel(); ByteBuffer buffer = ByteBuffer.allocate(1024); while (true) { int read = fci.read(buffer); if (read == -1) break; buffer.flip();// w ww . j av a 2 s. co m fco.write(buffer); buffer.clear(); } }
From source file:MainClass.java
public static void main(String[] a) throws Exception { String fileName = "BigFile.txt"; FileInputStream fis = new FileInputStream(fileName); JLabel filenameLabel = new JLabel(fileName, JLabel.RIGHT); Object message[] = { "Reading:", filenameLabel }; ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(null, message, fis); InputStreamReader isr = new InputStreamReader(pmis); BufferedReader br = new BufferedReader(isr); String line;//from ww w . ja va2 s . co m while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); }
From source file:CopyBytes.java
public static void main(String[] args) throws IOException { File inputFile = new File("input.txt"); File outputFile = new File("output.txt"); FileInputStream in = new FileInputStream(inputFile); FileOutputStream out = new FileOutputStream(outputFile); int c;/*from w w w .ja v a2s . co m*/ while ((c = in.read()) != -1) out.write(c); in.close(); out.close(); }
From source file:CopyChannels.java
public static void main(String[] args) throws Exception { String fromFileName = "from.txt"; String toFileName = "to.txt"; FileChannel in = new FileInputStream(fromFileName).getChannel(); FileChannel out = new FileOutputStream(toFileName).getChannel(); ByteBuffer buff = ByteBuffer.allocate(32 * 1024); while (in.read(buff) > 0) { buff.flip();// w w w . ja v a 2 s . c om out.write(buff); buff.clear(); } in.close(); out.close(); }
From source file:BufferedCopy.java
public static void main(String[] args) throws Exception { BufferedInputStream bis = null; BufferedOutputStream bos = null; FileInputStream fis = new FileInputStream(args[0]); bis = new BufferedInputStream(fis); FileOutputStream fos = new FileOutputStream(args[1]); bos = new BufferedOutputStream(fos); int byte_; while ((byte_ = bis.read()) != -1) bos.write(byte_); }
From source file:Main.java
public static void main(String[] args) throws Exception { Properties prop = new Properties(); String fileName = "app.config"; InputStream is = new FileInputStream(fileName); prop.load(is);// w w w . ja va2 s . co m System.out.println(prop.getProperty("app.name")); System.out.println(prop.getProperty("app.version")); System.out.println(prop.getProperty("app.vendor", "Java")); }
From source file:MainClass.java
public static void main(String args[]) throws Exception { char[] oldpass = args[0].toCharArray(); char[] newpass = args[1].toCharArray(); String name = "mykeystore"; FileInputStream in = new FileInputStream(name); KeyStore ks = KeyStore.getInstance("JKS"); ks.load(in, oldpass);//from w ww.ja v a 2 s. c o m in.close(); FileOutputStream output = new FileOutputStream(name); ks.store(output, newpass); output.close(); }
From source file:Main.java
public static void main(String[] args) { File file = null;/*from ww w . j a v a 2s .c o m*/ WordExtractor extractor = null; try { file = new File("c:\\New.doc"); FileInputStream fis = new FileInputStream(file.getAbsolutePath()); HWPFDocument document = new HWPFDocument(fis); extractor = new WordExtractor(document); String[] fileData = extractor.getParagraphText(); for (int i = 0; i < fileData.length; i++) { if (fileData[i] != null) System.out.println(fileData[i]); } } catch (Exception exep) { } }
From source file:Converter.java
public static void main(String args[]) throws Exception { FileInputStream fis = new FileInputStream(new File("input.txt")); BufferedReader in = new BufferedReader(new InputStreamReader(fis, "SJIS")); FileOutputStream fos = new FileOutputStream(new File("output.txt")); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(fos, "UTF8")); int len = 80; char buf[] = new char[len]; int numRead;/*from w w w .j ava2s. c o m*/ while ((numRead = in.read(buf, 0, len)) != -1) out.write(buf, 0, numRead); out.close(); in.close(); }