if (v == ipSpeichern_btn) {
player=new Mediaplayerdoc(ip);
String id=player.server();
new AlertDialog.Builder(this)
.setMessage("port"+id)
.setNeutralButton("port"+id, null).show();
}
public class Mediaplayerdoc {
String ipadresse;
public Mediaplayerdoc(String ipadresse) {
super();
this.ipadresse = ipadresse;
}
public String server() {
String i = "l";
try {
i = null;
i = "Host Name/Adresse: " + InetAddress.getLocalHost();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
Socket server = new Socket("192.168.1.20", 1235); // habe es auch schon mit dem localhost versucht
OutputStream out = server.getOutputStream();
String a = "bla";
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out));
bw.write(a);
bw.newLine();
bw.write(a);
bw.newLine();
bw.flush();
out.close();
}
// Exceptions abfangen
catch (IOException error) {
}
return i;
}
public class Server {
void aufbau() {
try {
ServerSocket server = new ServerSocket(1235);
server.setSoTimeout(10000);// 30 sec
while (true) {
System.out.println("Warte auf Client");
Socket client = server.accept();
System.out.println("Mit Client verbunden"
+ client.getInetAddress());
InputStream input = client.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(
input));
File file = new File("text.txt");
FileWriter fw = new FileWriter(file);
String s;
while ((s = br.readLine()) != null) {
System.out.println(s);
fw.write(s + "\n");
}
fw.close();
}
} catch (java.net.SocketTimeoutException error) {
System.err.println("Kein Client Fragt an ");
} catch (IOException error) {
System.err.println("Fehler: " + error);
}
}
}
System.out.println();
dann habe ich noch eine frage gibt es so was ähnliches wieJava:System.out.println();