public static void broadcast(byte[] data, int port) throws IOException { DatagramSocket socket = null; try { socket = new DatagramSocket(); broadcast(socket, data, port, NetworkInterface.getNetworkInterfaces()); } finally { StreamUtils.closeQuietly(socket); } }
private void onOK() { BufferedWriter bw = null; try { File temp = File.createTempFile("import_images_from_url", ".txt"); bw = new BufferedWriter(new FileWriter(temp)); bw.write(txtDeckList.getText()); tmpPath = temp.getPath(); } catch (IOException e) { e.printStackTrace(); } finally { StreamUtils.closeQuietly(bw); } dispose(); }
private void onOK() { BufferedWriter bw = null; try { File temp = File.createTempFile("cbimportdeck", ".txt"); bw = new BufferedWriter(new FileWriter(temp)); bw.write(txtDeckList.getText()); tmpPath = temp.getPath(); } catch (IOException e) { e.printStackTrace(); } finally { StreamUtils.closeQuietly(bw); } dispose(); }
public T copy(T obj) { T copy = null; FastByteArrayOutputStream fbos = null; ObjectOutputStream out = null; ObjectInputStream in = null; try { fbos = new FastByteArrayOutputStream(); out = new ObjectOutputStream(fbos); // Write the object out to a byte array out.writeObject(obj); out.flush(); // Retrieve an input stream from the byte array and read // a copy of the object back in. in = new CopierObjectInputStream(loader, fbos.getInputStream()); copy = (T) in.readObject(); } catch(IOException | ClassNotFoundException e) { e.printStackTrace(); } finally { StreamUtils.closeQuietly(fbos); StreamUtils.closeQuietly(out); StreamUtils.closeQuietly(in); } return copy; }
throw new RuntimeException("Entry point not an instance of ExtensionPackage.", e); } finally { StreamUtils.closeQuietly(classLoader);
public byte[] copyCompressed(T obj) { FastByteArrayOutputStream fbos = null; ObjectOutputStream out = null; try { fbos = new FastByteArrayOutputStream(); out = new ObjectOutputStream(new GZIPOutputStream(fbos)); // Write the object out to a byte array out.writeObject(obj); out.flush(); byte[] copy = new byte[fbos.getSize()]; System.arraycopy(fbos.getByteArray(), 0, copy, 0, fbos.getSize()); return copy; } catch(IOException e) { e.printStackTrace(); } finally { StreamUtils.closeQuietly(fbos); StreamUtils.closeQuietly(out); } return null; }