List of usage examples for java.io DataInputStream readUTF
public final String readUTF() throws IOException
readUTF
method of DataInput
. From source file:com.facebook.infrastructure.db.Column.java
public IColumn deserialize(DataInputStream dis) throws IOException { String name = dis.readUTF(); return defreeze(dis, name); }
From source file:delete.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// ww w.j a v a2 s . c o m * * @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.serenegiant.media.TLMediaEncoder.java
static MediaFormat readFormat(final DataInputStream in) { MediaFormat format = null;//ww w . ja v a 2 s. c om try { readHeader(in); in.readUTF(); // skip MediaFormat data for configure format = asMediaFormat(in.readUTF()); } catch (IOException e) { Log.e(TAG_STATIC, "readFormat:", e); } if (DEBUG) Log.v(TAG_STATIC, "readFormat:format=" + format); return format; }
From source file:com.ryan.ryanreader.cache.PersistentCookieStore.java
public PersistentCookieStore(final byte[] data) throws IOException { final DataInputStream dis = new DataInputStream(new ByteArrayInputStream(data)); final int len = dis.readInt(); for (int i = 0; i < len; i++) { final String name = dis.readUTF(); final String value = dis.readUTF(); final String domain = dis.readUTF(); final String path = dis.readUTF(); final boolean isSecure = dis.readBoolean(); final BasicClientCookie cookie = new BasicClientCookie(name, value); cookie.setDomain(domain);/* w w w . j a v a 2 s . c om*/ cookie.setPath(path); cookie.setSecure(isSecure); cookies.add(cookie); } }
From source file:com.facebook.infrastructure.db.Column.java
public void skip(DataInputStream dis) throws IOException { /* read the column name */ dis.readUTF(); /* boolean indicating if the column is deleted */ dis.readBoolean();//from w w w. j a v a 2s .c om /* timestamp associated with the column */ dis.readLong(); /* size of the column */ int size = dis.readInt(); dis.skip(size); }
From source file:org.openxdata.server.serializer.JavaRosaXformSerializer.java
/** * Deserializes forms.// w w w.j a v a2s . c o m * * @return returns an List<String> of deserialized forms */ @Override public List<String> deSerialize(InputStream in, Map<Integer, String> map) { List<String> forms = new ArrayList<String>(); DataInputStream dis = new DataInputStream(in); try { int len = dis.readByte(); for (int i = 0; i < len; i++) forms.add(dis.readUTF()); } catch (IOException e) { throw new UnexpectedException(e); } return forms; }
From source file:org.openxdata.server.FormsServer.java
/** * Called when a new connection has been received. Failures are not handled * in this class as different servers (BT,SMS, etc) may want to handle them * differently.//w ww . j av a 2 s. co m * * @param dis - the stream to read from. * @param dos - the stream to write to. */ public void processConnection(InputStream disParam, OutputStream dosParam) { ZOutputStream gzip = new ZOutputStream(dosParam, JZlib.Z_BEST_COMPRESSION); DataOutputStream zdos = new DataOutputStream(gzip); byte responseStatus = ResponseStatus.STATUS_ERROR; try { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataInputStream dis = new DataInputStream(disParam); String name = dis.readUTF(); String password = dis.readUTF(); String serializer = dis.readUTF(); String locale = dis.readUTF(); byte action = dis.readByte(); User user = authenticationService.authenticate(name, password); if (user == null) responseStatus = ResponseStatus.STATUS_ACCESS_DENIED; else { DataOutputStream dosTemp = new DataOutputStream(baos); if (action == ACTION_DOWNLOAD_FORMS) formDownloadService.downloadForms(dosTemp, serializer, locale); else if (action == ACTION_UPLOAD_DATA) submitXforms(dis, dosTemp, serializer); else if (action == ACTION_DOWNLOAD_USERS) formDownloadService.downloadUsers(dosTemp, serializer); else if (action == ACTION_DOWNLOAD_USERS_AND_FORMS) downloadUsersAndForms(dis.readInt(), dosTemp, serializer, locale); else if (action == ACTION_DOWNLOAD_STUDY_LIST) formDownloadService.downloadStudies(dosTemp, serializer, locale); else if (action == ACTION_DOWNLOAD_LANGUAGES) formDownloadService.downloadLocales(dis, dosTemp, serializer); else if (action == ACTION_DOWNLOAD_MENU_TEXT) formDownloadService.downloadMenuText(dis, dosTemp, serializer, locale); else if (action == ACTION_DOWNLOAD_STUDY_FORMS) formDownloadService.downloadForms(dis.readInt(), zdos, serializer, locale); else if (action == ACTION_DOWNLOAD_USERS_AND_ALL_FORMS) downloadUsersAndAllForms(dosTemp, serializer, locale); responseStatus = ResponseStatus.STATUS_SUCCESS; } zdos.writeByte(responseStatus); if (responseStatus == ResponseStatus.STATUS_SUCCESS) { zdos.write(baos.toByteArray()); } } catch (Exception ex) { log.error(ex.getMessage(), ex); zdos.writeByte(responseStatus); } finally { zdos.flush(); gzip.finish(); } } catch (IOException e) { // this is for exceptions occurring in the catch or finally clauses. log.error(e.getMessage(), e); } }
From source file:com.github.terma.m.server.Repo.java
public Map<String, Short> readMetricCodes() throws IOException { Map<String, Short> result = new HashMap<>(); DataInputStream ois = null; try {// w ww .jav a 2 s .c om ois = new DataInputStream(new FileInputStream(eventCodesFile)); //noinspection InfiniteLoopStatement while (true) { result.put(ois.readUTF(), ois.readShort()); } } catch (EOFException | FileNotFoundException e) { // just end } finally { IOUtils.closeQuietly(ois); } return result; }
From source file:srvmonitor.thMonitorSocket.java
@Override public void run() { try {/*from www. j a v a2 s . c om*/ 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:org.nuxeo.apidoc.introspection.BundleIdReader.java
public synchronized void load(File file) { DataInputStream in = null; try {/*from w w w . ja v a 2 s . c om*/ in = new DataInputStream(new BufferedInputStream(new FileInputStream(file))); count = in.readLong(); int size = in.readInt(); for (int i = 0; i < size; i++) { String key = in.readUTF(); long id = in.readLong(); ids.put(key, Long.valueOf(id)); } } catch (FileNotFoundException e) { // do nothing - this is the first time the runtime is started } catch (IOException e) { log.error("The bundle.ids file is corrupted. Resetting bundle ids."); } finally { if (in != null) { try { in.close(); } catch (IOException e) { } } } }