Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Speicherort bei JFileChooser?

Empfohlene Antworten

Hallo und Guten Morgen,

so hab folgendes Problem, als ziemlicher neuling in Java!

Ich will eine Datei abspeichern, jedoch übernimmt er mir nicht den Pfad, wo ich die datei abspeichern will! Er speichert mir die Datei dann immer in Workspace von Java, wass soll ich machen, damit er mir die Datei unter dem richtigen Pfad abspeichert??

		public void actionPerformed(ActionEvent ae){
if(ae.getActionCommand()=="Export"){
JFileChooser fc=new JFileChooser(System.getProperty("user.dir"));

String datefromto;
Date von;
Date bis;

datefromto = jtfDateFrom.getText();
von = StringUtils.toDate(datefromto);

datefromto = jtfDateTo.getText();
bis = StringUtils.toDate(datefromto);


String s = jcbName.getSelectedItem() +"-"+ jtfDateFrom.getText()+"-"+ jtfDateTo.getText() + ".xls";
fc.setSelectedFile(new File(s));
int fd=fc.showSaveDialog(f);

try{
if(fd==JFileChooser.APPROVE_OPTION){

String sBenName = jcbName.getItemAt(jcbName.getSelectedIndex()).toString();
System.out.println(sBenName);

Vector vTemp = (Vector) vData.get(jcbName.getSelectedIndex());
String idBen = vTemp.get(1).toString();
System.out.println(idBen);

Main main = new Main();
main.export(idBen,von,bis,fc.getSelectedFile().getName());

FileOutputStream fo=new FileOutputStream(fc.getSelectedFile());
}
}
catch(Exception ex){}
}
else if (ae.getActionCommand()=="Close"){
f.dispose();
}
}[/PHP]

DANKE

MFG

MIKE

komlettes update:

		public void actionPerformed(ActionEvent ae){
if(ae.getActionCommand()=="Export"){
JFileChooser fc=new JFileChooser(System.getProperty("user.dir"));

String datefromto;
Date von;
Date bis;

datefromto = jtfDateFrom.getText();
von = StringUtils.toDate(datefromto);

datefromto = jtfDateTo.getText();
bis = StringUtils.toDate(datefromto);


String s = jcbName.getSelectedItem() +"-"+ jtfDateFrom.getText()+"-"+ jtfDateTo.getText() + ".xls";
fc.setSelectedFile(new File(s));
int fd=fc.showSaveDialog(f);

try{
if(fd==JFileChooser.APPROVE_OPTION){

String sBenName = jcbName.getItemAt(jcbName.getSelectedIndex()).toString();
System.out.println(sBenName);

Vector vTemp = (Vector) vData.get(jcbName.getSelectedIndex());
String idBen = vTemp.get(1).toString();
System.out.println(idBen);

Main main = new Main();
main.export(idBen,von,bis,fc.getCurrentDirectory() + "/" + fc.getSelectedFile().getName());
}
}
catch(Exception ex){
return;
}
}
else if (ae.getActionCommand()=="Close"){
f.dispose();
}
}
[/PHP]

Also das mit dem pfad passt jetzt!

Gibt es sonst eigentlich noch was am code aus zu setzten?

Bin für jeden tipp dankbar!

MFG

MIKE

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Konto

Navigation

Suchen

Suchen

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.