List of usage examples for java.io FileOutputStream FileOutputStream
public FileOutputStream(FileDescriptor fdObj)
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document.compress = false;/*from www . j a v a2 s.co m*/ Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open(); document.add(new Paragraph("this is a test.")); PdfContentByte cb = writer.getDirectContent(); cb.moveTo(30, 70); cb.lineTo(49, 70); cb.lineTo(49, 80); cb.lineTo(30, 80); cb.closePath(); cb.rectangle(30, 700, 460, 100); document.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("HelloWorldStamper.pdf")); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); PdfContentByte over;/*from w ww. j a v a2 s . c o m*/ int total = reader.getNumberOfPages() + 1; for (int i = 1; i < total; i++) { over = stamper.getOverContent(i); over.beginText(); over.setFontAndSize(bf, 18); over.setTextMatrix(30, 30); over.showText("page " + i); over.endText(); over.setRGBColorStroke(0xFF, 0x00, 0x00); over.setLineWidth(5f); over.ellipse(250, 450, 350, 550); over.stroke(); } stamper.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { ObjectOutputStream out = new ObjectOutputStream( new BufferedOutputStream(new FileOutputStream("file.data"))); out.write("java2s.com".getBytes(), 1, 2); out.close();/* w w w.j av a 2 s. c om*/ ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream("file.data"))); byte[] byteArray = new byte[10]; in.read(byteArray); System.out.println(Arrays.toString(byteArray)); in.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { ObjectOutputStream out = new ObjectOutputStream( new BufferedOutputStream(new FileOutputStream("file.data"))); out.writeChars("java2s.com"); out.close();// w w w . j a va 2s . c o m ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream("file.data"))); byte[] byteArray = new byte[10]; in.read(byteArray); System.out.println(Arrays.toString(byteArray)); in.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { ObjectOutputStream out = new ObjectOutputStream( new BufferedOutputStream(new FileOutputStream("file.data"))); out.writeDouble(1.234);//from ww w. j a va 2 s . c o m out.close(); ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream("file.data"))); byte[] byteArray = new byte[10]; in.read(byteArray); System.out.println(Arrays.toString(byteArray)); in.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(PageSize.A5, 36, 72, 108, 180); PdfWriter.getInstance(document, new FileOutputStream("MirroredMargins.pdf")); document.setMarginMirroring(true);/*w w w . java 2 s . c om*/ document.open(); document.add(new Paragraph("this is a test")); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(Element.ALIGN_JUSTIFIED); for (int i = 0; i < 20; i++) { paragraph.add("Hello World"); } document.add(paragraph); document.add(new Paragraph("this is a test")); document.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")); writer.setViewerPreferences(PdfWriter.PageModeUseOutlines); document.open();//from ww w . j av a 2s. c o m Phrase text = new Phrase("test. "); ChapterAutoNumber chapter1 = new ChapterAutoNumber("This is a sample sentence:"); chapter1.setBookmarkTitle("The fox"); chapter1.setBookmarkOpen(false); Section section1 = chapter1.addSection("Quick"); section1.add(text); document.add(chapter1); ChapterAutoNumber chapter2 = new ChapterAutoNumber("Jumps"); Section section = chapter2.addSection("Over"); section.add(text); document.add(chapter2); document.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { ObjectOutputStream out = new ObjectOutputStream( new BufferedOutputStream(new FileOutputStream("file.data"))); out.write(1);//from w ww . ja v a 2 s . c o m out.close(); ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream("file.data"))); byte[] byteArray = new byte[10]; in.read(byteArray); System.out.println(Arrays.toString(byteArray)); in.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { ObjectOutputStream out = new ObjectOutputStream( new BufferedOutputStream(new FileOutputStream("file.data"))); out.writeShort(1);/* w w w.j ava 2 s . co m*/ out.close(); ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream("file.data"))); byte[] byteArray = new byte[10]; in.read(byteArray); System.out.println(Arrays.toString(byteArray)); in.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { ObjectOutputStream out = new ObjectOutputStream( new BufferedOutputStream(new FileOutputStream("file.data"))); out.writeBoolean(true);//from w w w.j a v a 2s .c o m out.close(); ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream("file.data"))); byte[] byteArray = new byte[10]; in.read(byteArray); System.out.println(Arrays.toString(byteArray)); in.close(); }