Hirdetés
Új hozzászólás Aktív témák
-
n00n
őstag
A legegyszerűbb, ha ideírom a forráskódot:
class Copy extends SwingWorker<Void, Void> {
private File selectedfile = new File("D:/Adatok/proba.file");
private File chosenDestination = new File("D:/Adatok/ide/proba.file");
@Override
protected Void doInBackground() throws Exception {
try {
FileInputStream fileInputStream = new FileInputStream(
selectedfile);
BufferedInputStream bufferedInputStream = new BufferedInputStream(
fileInputStream);
ProgressMonitorInputStream progressMonitorInputStream;
UIManager.put("ProgressMonitor.progressText", "Mentés másolása");
UIManager.put("OptionPane.cancelButtonText", "Mégse");
progressMonitorInputStream = new ProgressMonitorInputStream(MentesPanel.this, "Fájl másolása folyamatban", bufferedInputStream);
File outputFile = new File("" + chosenDestination);
FileOutputStream fileOutputStream = new FileOutputStream(
outputFile);
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(
fileOutputStream);
int data;
byte[] buffer = new byte[1024];
while ((data = progressMonitorInputStream.read(buffer)) > 0) {
bufferedOutputStream.write(buffer);
}
bufferedOutputStream.close();
progressMonitorInputStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
public void done() {
JOptionPane.showMessageDialog(MentesPanel.this, "A mentés másolása befejeződött!", "Kész", 1);
}
}
}
Új hozzászólás Aktív témák
A topicot kiemeltem. Valaki nem akar egy nyitó hsz-t írni?:))
- HUAWEI MateBook 13 2020 - Kijelző nélkül - I7-10510U - 16GB - 512GB SSD - Win11 - MAGYAR
- BESZÁMÍTÁS! MSI X370 R5 2600 16GB DDR4 512GB SSD GTX 970 4GB Zalman Z9 Neo FSP 600W
- Samsung Galaxy A54 5G 128GB, Kártyafüggetlen, 1 Év Garanciával
- HP Victus 15-fb1002AX - 15,6"FHD IPS - Ryzen 5 7535HS - 8GB - 512GB SSD - RTX 2050 - Win11
- BESZÁMÍTÁS! Apple MacBook Pro 14 M4 Pro 24GB RAM 512GB SSD macbook garanciával hibátlan működéssel
Állásajánlatok
Cég: CAMERA-PRO Hungary Kft.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest