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 Exception { String fromFileName = "from.txt"; String toFileName = "to.txt"; FileChannel in = new FileInputStream(fromFileName).getChannel(); FileChannel out = new FileOutputStream(toFileName).getChannel(); in.transferTo(0, (int) in.size(), out); in.close();/* ww w.j a va2s.c om*/ out.close(); }
From source file:CirclesPDF.java
public static void main(String[] args) { Document document = new Document(); try {//from w w w. j a v a 2 s. co m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("CirclesPDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.circle(250.0f, 500.0f, 200.0f); cb.circle(250.0f, 500.0f, 150.0f); cb.circle(350.0f, 300.0f, 150.0f); cb.stroke(); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:Main.java
public static void main(String[] args) throws IOException { short[] s = { 123, 234 }; FileOutputStream fos = new FileOutputStream("c:\\test.txt"); DataOutputStream dos = new DataOutputStream(fos); for (short j : s) { dos.writeShort(j);//from w ww . jav a2 s. co m } dos.flush(); InputStream is = new FileInputStream("c:\\test.txt"); DataInputStream dis = new DataInputStream(is); while (dis.available() > 0) { short k = dis.readShort(); System.out.print(k); } }
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(); for (ByteBuffer buffer = ByteBuffer.allocate(1024 * 1024); inChannel.read(buffer) != -1; buffer.clear()) { buffer.flip();//from ww w. j a v a2s . c o m while (buffer.hasRemaining()) outChannel.write(buffer); } inChannel.close(); outChannel.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { String fromFileName = args[0]; String toFileName = args[1];/* ww w .j a v a2s. c o m*/ FileChannel in = new FileInputStream(fromFileName).getChannel(); FileChannel out = new FileOutputStream(toFileName).getChannel(); in.transferTo(0, (int) in.size(), out); in.close(); out.close(); }
From source file:Main.java
public static void main(String[] args) throws IOException { byte[] buf = { 65, 66, 67, 68, 69, 70 }; FileOutputStream fos = new FileOutputStream("c:\\test.txt"); DataOutputStream dos = new DataOutputStream(fos); for (byte b : buf) { dos.writeChar(b);/* w ww . j av a2 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:ShapeRectanglePDF.java
public static void main(String[] args) { Document document = new Document(); try {/* w w w. j a v a 2 s. co m*/ PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ShapeRectanglePDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.setLineWidth(10f); cb.rectangle(100, 700, 100, 100); cb.stroke(); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:NestedTablesWithoutPointPositionPDF.java
public static void main(String[] args) { Document document = new Document(); try {/* w w w . ja va 2 s. c o m*/ PdfWriter.getInstance(document, new FileOutputStream("NestedTablesWithoutPointPositionPDF.pdf")); document.open(); Table aTable = new Table(2, 2); // 4 rows, 4 columns aTable.setAutoFillEmptyCells(true); aTable.addCell("2.2"); aTable.addCell("2.1"); Table secondTable = new Table(2); secondTable.addCell("0.0"); secondTable.addCell("0.1"); aTable.insertTable(secondTable); aTable.addCell("2.2"); document.add(aTable); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("2.pdf")); document.open();// w w w . j a v a 2 s . co m ZapfDingbatsNumberList zapfdingbatsnumberlist; zapfdingbatsnumberlist = new ZapfDingbatsNumberList(0, 15); zapfdingbatsnumberlist.add(new ListItem("A")); zapfdingbatsnumberlist.add(new ListItem("B")); document.add(zapfdingbatsnumberlist); document.close(); }
From source file:StrokeLineWidthPDF.java
public static void main(String[] args) { Document document = new Document(); try {//from ww w . j ava2 s .c om PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("StrokeLineWidthPDF.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); cb.setLineWidth(10f); cb.rectangle(100, 700, 100, 100); cb.stroke(); } catch (Exception e) { System.err.println(e.getMessage()); } document.close(); }