public String getServiceAsJSON ( String id ) { String path = this . registeredConfigurations . get ( id ) ; if ( path == null ) { return null ; } // cargar fichero de disco obtener el json y parsearlo File f = new File ( CONFIGURATION_DIR + File . separator + path ) ; FileInputStream fis = null ; InputStream in = null ; OutputStream out = null ; String res = null ; try { fis = new FileInputStream ( f ) ; in = new BufferedInputStream ( fis , Constants . IO_BUFFER_SIZE ) ; final ByteArrayOutputStream dataStream = new ByteArrayOutputStream ( ) ; out = new BufferedOutputStream ( dataStream , Constants . IO_BUFFER_SIZE ) ; byte [ ] b = new byte [ 8 * 1024 ] ; int read ; while ( ( read = in . read ( b ) ) != - 1 ) { out . write ( b , 0 , read ) ; } out . flush ( ) ; res = new String ( dataStream . toByteArray ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; return null ; } finally { Constants . closeStream ( fis ) ; Constants . closeStream ( in ) ; Constants . closeStream ( out ) ; } return res ; }
Returns the content of the json document describing a service given its id