List of usage examples for java.io FileOutputStream FileOutputStream
public FileOutputStream(FileDescriptor fdObj)
From source file:Main.java
public static void main(String[] args) throws IOException { byte[] b = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; FileOutputStream fos = new FileOutputStream("c:\\test.txt"); DataOutputStream dos = new DataOutputStream(fos); for (byte j : b) { dos.writeByte(j);/*w w w . j av a 2s . c o m*/ } dos.flush(); InputStream is = new FileInputStream("c:\\test.txt"); DataInputStream dis = new DataInputStream(is); while (dis.available() > 0) { int k = dis.read(); System.out.print(k); dis.skipBytes(1); } }
From source file:Main.java
public static void main(String[] args) throws IOException { String s = "Hello from java2s.com!!"; FileOutputStream fos = new FileOutputStream("c:\\test.txt"); DataOutputStream dos = new DataOutputStream(fos); dos.writeChars(s);/*from w w w. j a va 2 s .c o m*/ dos.flush(); InputStream is = new FileInputStream("c:\\test.txt"); DataInputStream dis = new DataInputStream(is); while (dis.available() > 0) { char c = dis.readChar(); System.out.print(c); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { MyClass o = new MyClass(); o.setProp(1);/*from www .j a v a 2 s . c o m*/ o.setProps(new int[] { 1, 2, 3 }); XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream("outfilename.xml"))); encoder.writeObject(o); encoder.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();//from w ww . j av a 2s . c o m document.add(new Paragraph("This is a message.")); PdfAcroForm acroForm = writer.getAcroForm(); acroForm.addSignature("yoursig", 73, 705, 149, 759); document.close(); }
From source file:MainClass.java
public static void main(String[] args) throws IOException { FileInputStream inFile = new FileInputStream(args[0]); FileOutputStream outFile = new FileOutputStream(args[1]); FileChannel inChannel = inFile.getChannel(); FileChannel outChannel = outFile.getChannel(); FileLock outLock = outChannel.lock(); FileLock inLock = inChannel.lock(0, inChannel.size(), true); inChannel.transferTo(0, inChannel.size(), outChannel); outLock.release();/* w w w.jav a 2 s . c om*/ inLock.release(); inChannel.close(); outChannel.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { BufferedInputStream fin = new BufferedInputStream(new FileInputStream("in.dat")); BufferedOutputStream fout = new BufferedOutputStream(new FileOutputStream("out.dat")); int i;//from ww w . ja v a 2 s . co m do { i = fin.read(); if (i != -1) fout.write(i); } while (i != -1); fin.close(); fout.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { PdfReader reader = new PdfReader("HelloWorldRead.pdf"); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("HelloWorldStamper2.pdf")); int total = reader.getNumberOfPages() + 1; for (int i = 1; i < total; i++) { stamper.setRotateContents(false); PdfContentByte over = stamper.getOverContent(i); over.setRGBColorStroke(0xFF, 0x00, 0x00); over.setLineWidth(5f);/*from w w w .j a va 2 s . com*/ over.ellipse(250, 450, 350, 550); over.stroke(); } stamper.close(); }
From source file:HTMLListsAtoEPDF.java
public static void main(String[] args) { Document document = new Document(); try {/*from w w w. jav a 2 s .c o m*/ HtmlWriter.getInstance(document, new FileOutputStream("HTMLListsAtoEPDF.html")); document.open(); Paragraph paragraph = new Paragraph("A to E:"); List list = new List(false, 10); list.add("A"); list.add("B"); list.add("C"); list.add("D"); list.add("E"); paragraph.add(list); document.add(paragraph); } catch (Exception ioe) { System.err.println(ioe.getMessage()); } document.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document.compress = false;/*from ww w . ja v a 2s .com*/ Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("logo.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); String eye = "this is a test"; cb.setLiteral(eye); document.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream("clients.ser")); AccountRecordSerializable record;//ww w . java2s. c o m record = new AccountRecordSerializable(1, "firstName", "lastName", 0.1); output.writeObject(record); ObjectInputStream input = new ObjectInputStream(new FileInputStream("clients.ser")); record = (AccountRecordSerializable) input.readObject(); System.out.printf("%-10d%-12s%-12s%10.2f\n", record.getAccount(), record.getFirstName(), record.getLastName(), record.getBalance()); output.close(); }