public void encode(File file, OutputStream base64OutputStream) { InputStream is = new FileInputStream(file); OutputStream out = new Base64OutputStream(base64OutputStream) IOUtils.copy(is, out); is.close(); out.close(); }
... ByteArrayOutputStream os = new ByteArrayOutputStream(); OutputStream b64 = new Base64.OutputStream(os); ImageIO.write(bi, "png", b64); String result = os.toString("UTF-8");
OutputStream outputStream = new OutputStream(clientSocket.getOutputStream(), true);
OutputStream outstream = new OutputStream(urlConnection.getOutputStream());
OutputStream output = new OutputStream("SomePath");
File file = new TFile("archive.tar.gz/README.TXT"); OutputStream out = new TFileOutputStream(file); try { // Write archive entry contents here. ... } finally { out.close(); }
OutputStream os = new OutputStream(file); OutputStreamWriter writer = new OutputStreamWriter(os, "UTF-8");
public void encode(File file, OutputStream base64OutputStream) { InputStream is = new FileInputStream(file); OutputStream out = new Base64OutputStream(base64OutputStream) IOUtils.copy(is, out); is.close(); out.close(); }
OutputStream os = new LogOutputStream(); PrintStream ps = new PrintStream(os); System.setOut(ps);
public void encode(File file, OutputStream base64OutputStream) { InputStream is = new FileInputStream(file); OutputStream out = new Base64OutputStream(base64OutputStream) IOUtils.copy(is, out); is.close(); out.close(); }
public byte[] crtZipByteArray(ByteArrayInputStream data,ZipEntry entry) throws IOException{ ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); OutputStream fileOut = new FileOutputStream("filename.zip"); OutputStream teeOut = new TeeOutputStream(byteArrayOut, fileOut); ZipOutputStream zos = new ZipOutputStream(teeOut); ..... }
OutputStream outstream = new OutputStream(socket.getOutputStream()); PrintWriter out = new PrintWriter(outstream); out.write("Hello Server!");
OutputStream printStream = new OutputStream(new FileOutputStream("someText.txt", true)); System.setOut(printStream);
File file = new File("abc.xlsx"); FileWriter writer = new FileWriter(file); OutputStream outputStream = new WriterOutputStream(writer); PrintStream printStream = new PrintStream(outputStream);
StringBuilder sb = new StringBuilder(); try (OutputStream out = new Base64Encoder(sb)) { javax.imageio.ImageIO.write(image, "png", out); } catch (IOException e) { throw new RuntimeException(e); } String imageData = sb.toString();
ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = new CompositeOutputStream(new DataOutputStream(...), baos); os.write(...); byte[] data = baos.toByteArray(); String dataAsString = new String(data, "UTF-8"); // or whatever encoding you are using // etc.
// Directory to save log files in File logDir = new File("/var/log/myapp"); // Name of log file String logFileName = locations[0][0] + "-" + locations[0][1] + "-output.txt"; // Actual log file File logFile = new File(logDir, logFileName); // File stream OutputStream fileStream = new FileOutputStream(logFile); // Stdout OutputStream stdioStream = System.out; // A stream redirecting output to both supplied streams OutputStream combinedStream = new TeeOutputStream(stdioStream, fileStream); // Finally use the resulting stream System.setOut(new PrintStream(combinedStream));
@FXML protected void onClick(ActionEvent event) throws FileNotFoundException{ Properties p = new Properties(); InputStream is = new InputStream("accounts.txt"); p.load(is); is.close(); String number = banknumber.getText(); String origbal = p.getProperty(number); int addtobal = Integer.parseInt(deposited.getText()); if (origbal != null) p.setProperty(number, Integer.parseInt(origbal) + addtobal); OutputStream os = new OutputStream("accounts.txt"); p.store(os); os.close(); }
public String hex() { final StringBuilder buf = new StringBuilder(); try { pipe(new OutputStream() { @Override public void write(int b) { String s = Integer.toHexString(0xff & b); if (s.length() < 2) buf.append("0"); buf.append(s); } }); } catch (IOException ioe) { throw new RuntimeException("impossible"); } return buf.toString(); }
try (InputStream is = new InputStream(socket); OutputStream os = new OutputStream(socket); ObjectInputStream ois = new ObjectInputStream(is) ObjectOutputStream oos = new ObjectInputStream(os)) { // Do stuff here }