| | |
| | | import com.google.gson.Gson; |
| | | import com.sun.net.httpserver.HttpExchange; |
| | | import com.sun.net.httpserver.HttpHandler; |
| | | import de.uhilger.mediaz.entity.Ablage; |
| | | import de.uhilger.mediaz.entity.Ablageort; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | |
| | | |
| | | @Override |
| | | public void handle(HttpExchange e) throws IOException { |
| | | Ablage ablage = new Ablage(); |
| | | ablage.setName("Katalog"); |
| | | ablage.setOrt("/home/ulrich/Videos"); |
| | | Ablageort ablageort = new Ablageort(); |
| | | ablageort.setName("Katalog"); |
| | | ablageort.setOrt("/home/ulrich/Videos"); |
| | | ablageort.setUrl("/media/test"); |
| | | |
| | | Gson gson = new Gson(); |
| | | File mediaOrdner = new File(ablage.getOrt()); |
| | | File mediaOrdner = new File(ablageort.getOrt()); |
| | | File[] files = mediaOrdner.listFiles(); |
| | | String json = gson.toJson(files); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append(json); |
| | | |
| | | json = gson.toJson(ablage); |
| | | json = gson.toJson(ablageort); |
| | | sb.append(json); |
| | | |
| | | byte[] b = sb.toString().getBytes(); |