List of usage examples for java.io DataOutputStream writeUTF
public final void writeUTF(String str) throws IOException
From source file:io.dacopancm.socketdcm.net.StreamSocket.java
public ObservableList<StreamFile> getStreamList() { ObservableList<StreamFile> list = FXCollections.observableArrayList(); try {//from w ww .j a v a2s .com if (ConectType.GET_STREAMLIST.name().equalsIgnoreCase(method)) { logger.log(Level.INFO, "get stream list call"); sock = new Socket(ip, port); DataOutputStream dOut = new DataOutputStream(sock.getOutputStream()); DataInputStream dIn = new DataInputStream(sock.getInputStream()); dOut.writeUTF(ConectType.STREAM.name());//send stream type dOut.writeUTF("uncompressed");//send comprimido o no dOut.writeUTF(ConectType.GET_STREAMLIST.toString()); //send type dOut.writeUTF("mayra"); dOut.flush(); // Send off the data System.out.println("Request list send"); String resp = dIn.readUTF(); dOut.close(); logger.log(Level.INFO, "resp get streamlist: {0}", resp); List<StreamFile> files = HelperUtil.fromJSON(resp); list.addAll(files); } } catch (IOException ex) { HelperUtil.showErrorB("No se pudo establecer conexin"); logger.log(Level.INFO, "get streamlist error no connect:{0}", ex.getMessage()); try { if (sock != null) { sock.close(); } } catch (IOException e) { } } return list; }
From source file:io.dacopancm.socketdcm.net.StreamSocket.java
public String getStreamFile() { String list = "false"; try {/* www.ja v a2 s . c om*/ if (ConectType.GET_STREAM.name().equalsIgnoreCase(method)) { logger.log(Level.INFO, "get stream socket call"); sock = new Socket(ip, port); DataOutputStream dOut = new DataOutputStream(sock.getOutputStream()); DataInputStream dIn = new DataInputStream(sock.getInputStream()); dOut.writeUTF(ConectType.STREAM.name());//send stream type dOut.writeUTF("uncompressed");//send comprimido o no dOut.writeUTF(ConectType.GET_STREAM.toString()); //send type dOut.writeUTF(streamid); dOut.flush(); // Send off the data String rtspId = dIn.readUTF(); dOut.close(); logger.log(Level.INFO, "resp get stream file: {0}", rtspId); list = rtspId; } } catch (IOException ex) { HelperUtil.showErrorB("No se pudo establecer conexin"); logger.log(Level.INFO, "get stream file error no connect:{0}", ex.getMessage()); try { if (sock != null) { sock.close(); } } catch (IOException e) { } } return list; }
From source file:com.facebook.infrastructure.db.RowMutation.java
public void serialize(RowMutation rm, DataOutputStream dos) throws IOException { dos.writeUTF(rm.table()); dos.writeUTF(rm.key());/*w w w . j a va 2s . c om*/ /* serialize the modifications_ in the mutation */ freezeTheMaps(rm.modifications_, dos); }
From source file:SearchMixedRecordDataTypeExample.java
public void commandAction(Command command, Displayable displayable) { if (command == exit) { destroyApp(true);//from w w w .j a v a 2 s. c o m notifyDestroyed(); } else if (command == start) { try { recordstore = RecordStore.openRecordStore("myRecordStore", true); } catch (Exception error) { alert = new Alert("Error Creating", error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { byte[] outputRecord; String outputString[] = { "Adam", "Bob", "Mary" }; int outputInteger[] = { 15, 10, 5 }; ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); DataOutputStream outputDataStream = new DataOutputStream(outputStream); for (int x = 0; x < 3; x++) { outputDataStream.writeUTF(outputString[x]); outputDataStream.writeInt(outputInteger[x]); outputDataStream.flush(); outputRecord = outputStream.toByteArray(); recordstore.addRecord(outputRecord, 0, outputRecord.length); outputStream.reset(); } outputStream.close(); outputDataStream.close(); } catch (Exception error) { alert = new Alert("Error Writing", error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { String inputString; byte[] byteInputData = new byte[300]; ByteArrayInputStream inputStream = new ByteArrayInputStream(byteInputData); DataInputStream inputDataStream = new DataInputStream(inputStream); if (recordstore.getNumRecords() > 0) { filter = new Filter("Mary"); recordEnumeration = recordstore.enumerateRecords(filter, null, false); while (recordEnumeration.hasNextElement()) { recordstore.getRecord(recordEnumeration.nextRecordId(), byteInputData, 0); inputString = inputDataStream.readUTF() + " " + inputDataStream.readInt(); alert = new Alert("Reading", inputString, null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } } inputStream.close(); } catch (Exception error) { alert = new Alert("Error Reading", error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { recordstore.closeRecordStore(); } catch (Exception error) { alert = new Alert("Error Closing", error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } if (RecordStore.listRecordStores() != null) { try { RecordStore.deleteRecordStore("myRecordStore"); filter.filterClose(); recordEnumeration.destroy(); } catch (Exception error) { alert = new Alert("Error Removing", error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } } } }
From source file:org.eclipse.orion.internal.server.search.SearchActivator.java
private void writeIndexGeneration(File baseDir) { baseDir.mkdirs();//from w w w. j a va 2 s .c o m File generationFile = new File(baseDir, INDEX_GENERATION_FILE); DataOutputStream out = null; try { out = new DataOutputStream(new FileOutputStream(generationFile)); out.writeUTF(Integer.toString(CURRENT_INDEX_GENERATION)); } catch (IOException e) { String msg = "Error writing search index generation number. Subsequent restarts will discard and rebuild search index from scratch"; //$NON-NLS-1$ LogHelper.log(new Status(IStatus.ERROR, SearchActivator.PI_SEARCH, msg, e)); } finally { IOUtilities.safeClose(out); } }
From source file:srvmonitor.thMonitorSocket.java
@Override public void run() { try {// w w w . jav a 2 s . c o m logger.info("Starting Listener Thread Monitor Server port: " + gDatos.getServerInfo().getSrvPort()); ServerSocket skServidor = new ServerSocket(gDatos.getServerInfo().getSrvPort()); String inputData; String outputData; String dRequest; String dAuth; JSONObject jHeader; JSONObject jData; int result; while (isSocketActive) { Socket skCliente = skServidor.accept(); InputStream inpStr = skCliente.getInputStream(); DataInputStream dataInput = new DataInputStream(inpStr); //Espera Entrada // try { inputData = dataInput.readUTF(); logger.info("Recibiendo TX: " + inputData); jHeader = new JSONObject(inputData); jData = jHeader.getJSONObject("data"); dAuth = jHeader.getString("auth"); dRequest = jHeader.getString("request"); if (dAuth.equals(gDatos.getServerInfo().getAuthKey())) { switch (dRequest) { case "keepAlive": result = gSub.updateStatusService(jData.getJSONObject("ServiceStatus")); if (result == 0) { outputData = gSub .sendAssignedProc(jData.getJSONObject("ServiceStatus").getString("srvID")); } else { outputData = gSub.sendError(10); } break; case "getDate": outputData = gSub.sendDate(); break; case "getStatus": logger.info("ejecutando ... getStatusServices"); outputData = gSub.sendStatusServices(); break; case "putExecOSP": gSub.putExecOSP(inputData); outputData = gSub.sendOkTX(); break; case "sendPing": outputData = "OK"; break; default: outputData = gSub.sendError(99, "Error Desconocido..."); } } else { outputData = gSub.sendError(60); } } catch (IOException | JSONException e) { outputData = gSub.sendError(90); } //Envia Respuesta // OutputStream outStr = skCliente.getOutputStream(); DataOutputStream dataOutput = new DataOutputStream(outStr); logger.debug("Enviando respuesta: " + outputData); if (outputData == null) { dataOutput.writeUTF("{}"); } else { dataOutput.writeUTF(outputData); } //Cierra Todas las conexiones // inpStr.close(); dataInput.close(); skCliente.close(); } } catch (NumberFormatException | IOException e) { logger.error(e.getMessage()); } }
From source file:SortMixedRecordDataTypeExample.java
public void commandAction(Command command, Displayable displayable) { if (command == exit) { destroyApp(true);// w ww . j a va2 s. com notifyDestroyed(); } else if (command == start) { try { recordstore = RecordStore.openRecordStore("myRecordStore", true); } catch (Exception error) { alert = new Alert("Error Creating", error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { byte[] outputRecord; String outputString[] = { "Mary", "Bob", "Adam" }; int outputInteger[] = { 15, 10, 5 }; ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); DataOutputStream outputDataStream = new DataOutputStream(outputStream); for (int x = 0; x < 3; x++) { outputDataStream.writeUTF(outputString[x]); outputDataStream.writeInt(outputInteger[x]); outputDataStream.flush(); outputRecord = outputStream.toByteArray(); recordstore.addRecord(outputRecord, 0, outputRecord.length); outputStream.reset(); } outputStream.close(); outputDataStream.close(); } catch (Exception error) { alert = new Alert("Error Writing", error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { String[] inputString = new String[3]; int z = 0; byte[] byteInputData = new byte[300]; ByteArrayInputStream inputStream = new ByteArrayInputStream(byteInputData); DataInputStream inputDataStream = new DataInputStream(inputStream); StringBuffer buffer = new StringBuffer(); comparator = new Comparator(); recordEnumeration = recordstore.enumerateRecords(null, comparator, false); while (recordEnumeration.hasNextElement()) { recordstore.getRecord(recordEnumeration.nextRecordId(), byteInputData, 0); buffer.append(inputDataStream.readUTF()); buffer.append(inputDataStream.readInt()); buffer.append("\n"); inputDataStream.reset(); } alert = new Alert("Reading", buffer.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); inputDataStream.close(); inputStream.close(); } catch (Exception error) { alert = new Alert("Error Reading", error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } try { recordstore.closeRecordStore(); } catch (Exception error) { alert = new Alert("Error Closing", error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } if (RecordStore.listRecordStores() != null) { try { RecordStore.deleteRecordStore("myRecordStore"); comparator.compareClose(); recordEnumeration.destroy(); } catch (Exception error) { alert = new Alert("Error Removing", error.toString(), null, AlertType.WARNING); alert.setTimeout(Alert.FOREVER); display.setCurrent(alert); } } } }
From source file:org.openxdata.server.serializer.JavaRosaXformSerializer.java
@SuppressWarnings("unchecked") public void serializeUsers(OutputStream os, Object data) { List<Object[]> users = (List<Object[]>) data; DataOutputStream dos = new DataOutputStream(os); try {//from ww w. j a va2s. co m dos.writeByte(users.size()); for (Object[] user : users) { dos.writeInt((Integer) user[0]); dos.writeUTF((String) user[1]); dos.writeUTF((String) user[2]); dos.writeUTF((String) user[3]); } } catch (IOException e) { throw new UnexpectedException(e); } }
From source file:org.anonymous.dobroreaderme.networking.dobrochan.DobrochanApi.java
public void reply(String board, BoardThread thread, String name, String message, String subject, String captcha) {/*from w ww . j a va 2 s. c o m*/ HttpConnection c = null; try { c = HTTP.openPOSTConnection(dobrach.getHost() + "/" + board + "/post/new.xhtml"); c.setRequestProperty("Content-Type", "multipart/form-data"); c.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1734.0 Safari/537.36"); HTTP.writeCookies(c, Settings.getCookies()); DataOutputStream dos = c.openDataOutputStream(); dos.writeUTF(HTTP.urlEncode("thread_id=" + thread.getId() + "&task=post&name=" + name + "&message=" + message + "&subject=" + subject + "&captcha=" + captcha + "&password=" + Settings.password + "&scroll_to=" + thread.getId() + "&new_post=" + "&post_files_count=0" + "&goto=board")); dos.flush(); dos.close(); InputStream is = c.openInputStream(); System.out.println("message"); int ch; while ((ch = is.read()) != -1) { System.out.print((char) ch); } is.close(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:bankingclient.DKFrame.java
public DKFrame(MainFrame vmain) { initComponents();/*from w ww.ja va2s . c om*/ this.main = vmain; this.jTextField1.setText(""); this.jTextField2.setText(""); this.jTextField3.setText(""); this.jTextField4.setText(""); this.jTextField5.setText(""); this.setVisible(false); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (jTextField2.getText().equals(jTextField3.getText()) && NumberUtils.isNumber(jTextField4.getText()) && NumberUtils.isNumber(jTextField5.getText())) { try { Socket client = new Socket("113.22.46.207", 6013); String cusName = jTextField1.getText(); String pass = jTextField2.getText(); String sdt = jTextField4.getText(); String cmt = jTextField5.getText(); DataOutputStream dout = new DataOutputStream(client.getOutputStream()); dout.writeByte(1); dout.writeUTF(cusName + "\n" + pass + "\n" + sdt + "\n" + cmt); dout.flush(); DataInputStream din = new DataInputStream(client.getInputStream()); byte check = din.readByte(); if (check == 1) { JOptionPane.showMessageDialog(rootPane, "da dang ki tai khoan thanh cong"); } else { JOptionPane.showMessageDialog(rootPane, "dang ki tai khoan khong thanh cong"); } client.close(); } catch (Exception ee) { ee.printStackTrace(); } main.setVisible(true); DKFrame.this.setVisible(false); } else { JOptionPane.showMessageDialog(rootPane, "Nhap thong tin sai, moi nhap lai"); } } }); jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { main.setVisible(true); DKFrame.this.setVisible(false); } }); }