Hallo zusammen 
Ich habe Einen Code geschrieben der eine Ip an pingt und sagt ob er sie erreicht hat oder nicht nun habe ich auch noch einen Filewirter hinzugefügt nun habe ich einen error
Und mein Code:
Liebe Grüße
Kleines Update habe den erorr behoben aber leider ist spuckt er mir noch keine Datei aus !
Neuer Code:
Ich habe Einen Code geschrieben der eine Ip an pingt und sagt ob er sie erreicht hat oder nicht nun habe ich auch noch einen Filewirter hinzugefügt nun habe ich einen error
Java:
HelloWorld.java:27: error: class, interface, or enum expected import java.io.*;
Und mein Code:
Java:
import java.net.InetAddress;
import java.io.IOException;
import java.net.UnknownHostException;
public class HelloWorld {
public static void main(String[] args) throws UnknownHostException, IOException {
String ipAddress = "127.0.0.1";
InetAddress inet = InetAddress.getByName(ipAddress);
System.out.println("Sending Ping Request to " + ipAddress);
System.out.println(inet.isReachable(5000) ? "Host is reachable" : "Host is NOT reachable");
ipAddress = "193.196.202.6";
inet = InetAddress.getByName(ipAddress);
System.out.println("Sending Ping Request to " + ipAddress);
System.out.println(inet.isReachable(5000) ? "Host is reachable" : "Host is NOT reachable");
}
}
import java.io.*;
public class textoutput{
public static void main(String args[]) throws IOException{
File file = new File ("Hallo.txt");
// creates the file
file.createNewFile();
// creates a FileWriter Object
FileWriter writer = new FileWriter(file);
// Writes the content to the file
writer.write("");
writer.flush();
writer.close();
}
}
Liebe Grüße
Kleines Update habe den erorr behoben aber leider ist spuckt er mir noch keine Datei aus !
Neuer Code:
Java:
import java.net.InetAddress;
import java.io.IOException;
import java.net.UnknownHostException;
import java.io.*;
public class HelloWorld {
public static void main(String[] args) throws UnknownHostException, IOException {
String ipAddress = "127.0.0.1";
InetAddress inet = InetAddress.getByName(ipAddress);
System.out.println("Sending Ping Request to " + ipAddress);
System.out.println(inet.isReachable(5000) ? "Host is reachable" : "Host is NOT reachable");
ipAddress = "193.196.202.6";
inet = InetAddress.getByName(ipAddress);
System.out.println("Sending Ping Request to " + ipAddress);
System.out.println(inet.isReachable(5000) ? "Host is reachable" : "Host is NOT reachable");
}
}
class textoutput{
public static void main(String args[]) throws IOException{
File file = new File ("Hallo.txt");
// creates the file
file.createNewFile();
// creates a FileWriter Object
FileWriter writer = new FileWriter(file);
// Writes the content to the file
writer.write("");
writer.flush();
writer.close();
}
}
Zuletzt bearbeitet: