EMailsenden mit Datei bei Linux

BugsBastard

Erfahrenes Mitglied
Hallo zusammen,

ich muß ein EMail-Programm in Java schreiben, daß von einem Linux-Rechner aus eine Datei versendet. Unter Windows klappt das ganze auch ohne Probleme, nur unter Linux nicht. Nun dachte ich, daß es an den Dateipfaden liegt und habe den Pfad mal komplett ausgeschrieben. Aber auch das hat keine Änderung gebracht.

Was muß ich beachten wenn ich Dateien auf einem Linux-Rechner speichern bzw. herunterladen möchte was bei Windows anders ist? Ich habe die Dateien bislang in dem .war-Archiv gehabt unter web-inf/classes/dateiordner. Liegt hier vielleicht der Fehler?

Gruss und danke,

Thomas
 
Original geschrieben von BugsBastard
Hallo zusammen,

ich muß ein EMail-Programm in Java schreiben, daß von einem Linux-Rechner aus eine Datei versendet. Unter Windows klappt das ganze auch ohne Probleme, nur unter Linux nicht. Nun dachte ich, daß es an den Dateipfaden liegt und habe den Pfad mal komplett ausgeschrieben. Aber auch das hat keine Änderung gebracht.

Was muß ich beachten wenn ich Dateien auf einem Linux-Rechner speichern bzw. herunterladen möchte was bei Windows anders ist? Ich habe die Dateien bislang in dem .war-Archiv gehabt unter web-inf/classes/dateiordner. Liegt hier vielleicht der Fehler?

Gruss und danke,

Thomas

Ich hoffe du nutzt für dein Email Programm, die JavaMail API und sparst dir die Mühe alles selber zu kodieren.

Dein Dateipfad gibst du am besten unter zuhilfenahme des File.separator an.
Sprich String path = "WEB-INF"+File.separator+"myFolder"+ usw

Zudem ist es nicht gut Dateien unter WEB-INF/classes/* zu speichern.
 
Hi,

danke für die schnelle Antwort. Jup, ich verwende die JavaMail-API, das ganze klappt auch ganz wunderbar, allerdings nur unter Windows.

Wenn ich unter Linux einen Ordner unter dem Stamm-Verzeichnis (C:\ unter Windows meine ich) anlege, wie muß der dann angesprochen werden? Normalerweise doch mit /ordnername oder irr ich mich da? Kenn mich mit Linux nich so aus...

Gruss,

Thomas
 
Code:
listRoots

public static File[] listRoots()

    List the available filesystem roots.

    A particular Java platform may support zero or more hierarchically-organized file systems. Each file system has a root directory from which all other files in that file system can be reached. Windows platforms, for example, have a root directory for each active drive; UNIX platforms have a single root directory, namely "/". The set of available filesystem roots is affected by various system-level operations such the insertion or ejection of removable media and the disconnecting or unmounting of physical or virtual disk drives.

    This method returns an array of File objects that denote the root directories of the available filesystem roots. It is guaranteed that the canonical pathname of any file physically present on the local machine will begin with one of the roots returned by this method.

    The canonical pathname of a file that resides on some other machine and is accessed via a remote-filesystem protocol such as SMB or NFS may or may not begin with one of the roots returned by this method. If the pathname of a remote file is syntactically indistinguishable from the pathname of a local file then it will begin with one of the roots returned by this method. Thus, for example, File objects denoting the root directories of the mapped network drives of a Windows platform will be returned by this method, while File objects containing UNC pathnames will not be returned by this method.

    Unlike most methods in this class, this method does not throw security exceptions. If a security manager exists and its SecurityManager.checkRead(java.io.FileDescriptor) method denies read access to a particular root directory, then that directory will not appear in the result.

Returns:
    An array of File objects denoting the available filesystem roots, or null if the set of roots could not be determined. The array will be empty if there are no filesystem roots.
Since:
    1.2

Dadurch bekommst du alle Filesystem Roots als File Object.
Unter Windows währe das
C:\
D:\
usw :)=
 

Neue Beiträge

Zurück