G
Guest
Gast
hallo wie verschiebt man dateien?
habe nichts unter File gefunden
habe nichts unter File gefunden
import java.io.*;
class test {
public static void main(String[] arg){
File a = new File("C:\\rsdl.xpi");
File b = new File("C:\\temp");
if(a.exists()) System.out.println("A Korrekt");
if(b.exists()) System.out.println("B Korrekt");
try {copy(a,b); }
catch(IOException e) {System.out.println("Fehler");}
}
public static void copy(File src, File dst) throws IOException {
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
}
}
public void dateienEinordnen(){
String[] entries = new File( pfad + "SORTIEREN" ).list();
int j=0;
for(int i = 0; i < entries.length; i++){
j=0;
while(subFix[j] != null){
if ( entries[i].contains( subFix[j] ) == true) {
File datei = new File( pfad + "SORTIEREN"+entries[i] );
File dateiVer = new File( pfad + label[j] + entries[i] );
boolean dVersch = datei.renameTo(dateiVer);
if(dVersch == true )System.out.println("### Datei "+ entries[j] +" verschoben nach" + label[j]);
else System.out.println("!!! Fehler beim verschieben vom Ordner "+ label[j]);
}
j++;
}
//System.out.println(entries[i]);
}
}
public static void testFile(File file) {
System.out.println("test file: "+file.getAbsolutePath()+", exists?: "+file.exists());
}