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 { OutputStream out = null;/* www . j a v a2 s .c o m*/ JarFile f = new JarFile(args[0]); Pack200.Packer packer = Pack200.newPacker(); out = new FileOutputStream(args[0] + ".pack"); packer.pack(f, out); out.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();/*from ww w . j a v a2 s.co m*/ Font font = new Font(); font.setStyle(Font.UNDERLINE); Chunk chunk = new Chunk("java2s", font); chunk.setAnchor("http://www.java2s.com"); document.add(chunk); 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();//from w w w . ja v a2s . c o m String text = (char) 945 + " " + (char) 946 + " " + (char) 947; document.add(Phrase.getInstance(text)); document.add(Chunk.NEWLINE); for (int i = 913; i < 970; i++) { document.add(Phrase.getInstance(String.valueOf(i) + ": " + (char) i + " ")); } document.close(); }
From source file:Main.java
public static void main(String[] args) { byte[] b = { 'h', 'e', 'l', 'l', 'o' }; try {/*from w w w. ja v a2 s . c om*/ // create a new output stream OutputStream os = new FileOutputStream("test.txt"); // craete a new input stream InputStream is = new FileInputStream("test.txt"); // write something os.write(b); // read what we wrote for (int i = 0; i < b.length; i++) { System.out.print((char) is.read()); } os.close(); is.close(); } catch (Exception ex) { ex.printStackTrace(); } }
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*/ GreekList greeklist = new GreekList(20); greeklist.setGreekLower(true); greeklist.add(new ListItem("A")); greeklist.add(new ListItem("B")); document.add(greeklist); document.close(); }
From source file:Main.java
public static void main(String[] args) throws IOException { String outputFile = "a.zip"; int level = 9; FileOutputStream fout = new FileOutputStream(outputFile); ZipOutputStream zout = new ZipOutputStream(fout); zout.setLevel(level);/*from ww w .ja v a 2 s .c om*/ ZipEntry ze = new ZipEntry("a.zip"); FileInputStream fin = new FileInputStream("b.dat"); zout.putNextEntry(ze); for (int c = fin.read(); c != -1; c = fin.read()) { zout.write(c); } fin.close(); zout.close(); }
From source file:InputOutputDemoBinaryFile.java
public static void main(String[] a) throws Exception { //Write primitive values to a binary file "java2s.dat": DataOutputStream dos = new DataOutputStream(new FileOutputStream("java2s.dat")); dos.writeInt(228);// www. j a va 2s . c o m dos.writeChar(' '); dos.writeUTF("Java Source and Support at www.java2s.com"); dos.close(); //Read primitive values from binary file "java2s.dat": DataInputStream dis = new DataInputStream(new FileInputStream("java2s.dat")); System.out.println(dis.readInt() + "|" + dis.readChar() + "|" + dis.readUTF()); }
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();//from w w w .jav a 2s. c o m RomanList romanlist = new RomanList(20); romanlist.setRomanLower(false); romanlist.add(new ListItem("A")); romanlist.add(new ListItem("B")); document.add(romanlist); document.close(); }
From source file:Main.java
public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException { Formatter formatter = new Formatter(new FileOutputStream("generated/format.txt"), "ASCII", Locale.getDefault()); // format a new string String name = "from java2s.com"; formatter.format("Hello %s !", name); // print the formatted string System.out.println(formatter); // flush the formatter. Here it does nothing. formatter.flush();/*from ww w. j av a 2s .c o m*/ System.out.println("Formatter Flushed."); }
From source file:Main.java
public static void main(String[] args) throws Exception { FileChannel in = new FileInputStream("source.txt").getChannel(), out = new FileOutputStream("target.txt").getChannel(); ByteBuffer buffer = ByteBuffer.allocate(BSIZE); while (in.read(buffer) != -1) { buffer.flip();/*www .ja va 2 s . c om*/ out.write(buffer); buffer.clear(); } }