List of usage examples for java.io DataOutputStream writeUTF
public final void writeUTF(String str) throws IOException
From source file:org.pentaho.di.trans.dataservice.DataServiceExecutor.java
public static void writeMetadata(DataOutputStream dos, String... metadatas) throws IOException { for (String metadata : metadatas) { dos.writeUTF(metadata); }//www. ja va 2 s .com }
From source file:Main.java
public void run() { while (true) { try {/*www .j ava 2 s.c om*/ System.out.println("Waiting for client on port " + serverSocket.getLocalPort() + "..."); Socket server = serverSocket.accept(); System.out.println("Just connected to " + server.getRemoteSocketAddress()); DataInputStream in = new DataInputStream(server.getInputStream()); System.out.println(in.readUTF()); DataOutputStream out = new DataOutputStream(server.getOutputStream()); out.writeUTF("Thank you for connecting to " + server.getLocalSocketAddress() + "\nGoodbye!"); server.close(); } catch (SocketTimeoutException s) { System.out.println("Socket timed out!"); break; } catch (IOException e) { e.printStackTrace(); break; } } }
From source file:org.apache.cassandra.db.RangeCommand.java
public void serialize(RangeCommand command, DataOutputStream dos) throws IOException { dos.writeUTF(command.table); dos.writeUTF(command.columnFamily);/*from www .j a va2 s . c o m*/ dos.writeUTF(command.startWith); dos.writeUTF(command.stopAt); dos.writeInt(command.maxResults); }
From source file:net.brtly.monkeyboard.plugin.core.panel.PluginDockableLayout.java
@Override public void writeStream(DataOutputStream out) throws IOException { out.writeUTF(_id); // wirthe plugin id byte[] b = Bundle.toByteArray(_bundle); // write the size in bytes of the Bundle out.writeInt(b.length);/*from w ww . j a v a 2 s . com*/ out.write(b); // write the Bundle }
From source file:org.apache.cassandra.db.migration.SerializationsTest.java
private void testWrite() throws IOException, ConfigurationException { for (int i = 0; i < ksCount; i++) { String tableName = "Keyspace" + (i + 1); KSMetaData ksm = DatabaseDescriptor.getKSMetaData(tableName); UUID uuid = UUIDGen.makeType1UUIDFromHost(FBUtilities.getLocalAddress()); DatabaseDescriptor.clearTableDefinition(ksm, uuid); Migration m = new AddKeyspace(ksm); ByteBuffer bytes = m.serialize(); DataOutputStream out = getOutput("db.migration." + tableName + ".bin"); out.writeUTF(new String(Base64.encodeBase64(bytes.array()))); out.close();/* w w w .j a va 2s .c om*/ } }
From source file:com.microsoft.tfs.client.eclipse.resourcedata.ResourceData.java
/** * @return this object serialized to a byte array, or <code>null</code> if * there was a problem serializing *///w ww. j a v a 2 s . c om public byte[] toByteArray() { try { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final DataOutputStream dos = new DataOutputStream(os); dos.writeUTF(serverItem); dos.writeInt(changesetId); dos.close(); return os.toByteArray(); } catch (final IOException e) { log.error("Error serializing", e); //$NON-NLS-1$ return null; } }
From source file:org.openmrs.module.odkconnector.serialization.serializer.custom.SerializedCohortSerializer.java
/** * Write the data to the output stream./*from w ww .j a v a 2 s.co m*/ * * @param stream the output stream * @param data the data that need to be written to the output stream */ @Override public void write(final OutputStream stream, final Object data) throws IOException { SerializedCohort cohort = (SerializedCohort) data; DataOutputStream outputStream = new DataOutputStream(stream); outputStream.writeInt(cohort.getId()); outputStream.writeUTF(cohort.getName()); outputStream.flush(); }
From source file:org.openmrs.module.odkconnector.serialization.serializer.openmrs.CohortSerializer.java
/** * Write the data to the output stream./* w w w . j a v a 2 s.com*/ * * @param stream the output stream * @param data the data that need to be written to the output stream */ @Override public void write(final OutputStream stream, final Object data) throws IOException { Cohort cohort = (Cohort) data; DataOutputStream outputStream = new DataOutputStream(stream); outputStream.writeInt(cohort.getCohortId()); outputStream.writeUTF(cohort.getName()); outputStream.flush(); }
From source file:delete.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w . j a v a 2 s . com * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); Socket s = new Socket("localhost", 9999); DataInputStream in = new DataInputStream(s.getInputStream()); DataOutputStream outD = new DataOutputStream(s.getOutputStream()); outD.writeUTF(request.getParameter("employee_id")); in.readUTF(); s.close(); try (PrintWriter out = response.getWriter()) { /* TODO output your page here. You may use following sample code. */ out.println("Deleted"); } }
From source file:com.facebook.infrastructure.db.ReadResponse.java
public void serialize(ReadResponse rm, DataOutputStream dos) throws IOException { dos.writeUTF(rm.table()); dos.writeInt(rm.digest().length);/*from ww w. j av a 2 s .com*/ dos.write(rm.digest()); dos.writeBoolean(rm.isDigestQuery()); if (!rm.isDigestQuery() && rm.row() != null) { Row.serializer().serialize(rm.row(), dos); } }