Re: Trash Can and Sun

Discussion in 'Java' started by Volker Borchert, May 29, 2008.

  1. Kenneth P. Turvey wrote:

    |> I just ran into something interesting that I hadn't really thought of
    |> before. It is a feature that I really think is missing from Java.
    |>
    |> Shouldn't there be a system independent way to use the system trash can
    |> when deleting a file?

    What do you mean by "system trash can"? The only trash can near the
    system I am typing this on is the waste paper basket next to the door.

    --

    "I'm a doctor, not a mechanic." Dr Leonard McCoy <>
    "I'm a mechanic, not a doctor." Volker Borchert <>
     
    Volker Borchert, May 29, 2008
    #1
    1. Advertising

  2. Volker Borchert

    Arne Vajhøj Guest

    Volker Borchert wrote:
    > Kenneth P. Turvey wrote:
    > |> I just ran into something interesting that I hadn't really thought of
    > |> before. It is a feature that I really think is missing from Java.
    > |>
    > |> Shouldn't there be a system independent way to use the system trash can
    > |> when deleting a file?
    >
    > What do you mean by "system trash can"? The only trash can near the
    > system I am typing this on is the waste paper basket next to the door.


    Windows Recycle Bin and whatever it is called on other systems.

    Arne
     
    Arne Vajhøj, May 30, 2008
    #2
    1. Advertising

  3. Volker Borchert

    Tom Anderson Guest

    On Fri, 30 May 2008, Kenneth P. Turvey wrote:

    > On Thu, 29 May 2008 20:12:13 +0000, Volker Borchert wrote:
    >
    >> |> I just ran into something interesting that I hadn't really thought of
    >> |> before. It is a feature that I really think is missing from Java. |>
    >> |> Shouldn't there be a system independent way to use the system trash
    >> can |> when deleting a file?
    >>
    >> What do you mean by "system trash can"? The only trash can near the
    >> system I am typing this on is the waste paper basket next to the door.

    >
    > For those cases it would fall back to the normal, permanent, delete.


    Maybe. If the semantics of Desktop.moveToTrash(File) are that it moves
    something to the trash, then is a permanent delete a good fallback? If i
    let a user put things in the trash, but actually delete them, then later
    he finds out his files are gone forever, am i not guilty of misleading
    him?

    Another option would be to create a trash folder on systems which don't
    have it (~/.trash, maybe?), and move files there. The problem is their
    actual deletion - if this is a trashless system, it'll never get emptied!
    I guess you could put it in /{tmp,scr}/$USER/trash and hope that things in
    /tmp get automatically wiped now and then.

    If neither of those options are any good, there's only one option left:
    throw a TrashNotSupported (etc) exception on systems without a trashcan.

    I'm still annoyed that British versions of MacOS never localised the Trash
    to a Waste Paper Basket ...

    tom

    --
    Oh, well of course *everything* looks bad if you remember it
     
    Tom Anderson, May 30, 2008
    #3
  4. Kenneth P. Turvey wrote:
    > On Fri, 30 May 2008 14:22:21 +0100, Tom Anderson wrote:
    >> Maybe. If the semantics of Desktop.moveToTrash(File) are that it moves
    >> something to the trash, then is a permanent delete a good fallback? If i
    >> let a user put things in the trash, but actually delete them, then later
    >> he finds out his files are gone forever, am i not guilty of misleading
    >> him?

    >
    > An exception might be best I suppose.
    >
    > Actually maybe not. 99.9% of the time the exception will be handled by
    > deleting the file.


    But the 0.1% would be unhappy.

    Arne
     
    Arne Vajhøj, May 31, 2008
    #4
  5. Kenneth P. Turvey wrote:
    > I wish that Java had a method for specifying default exception handlers
    > for cases when the exception isn't caught. Maybe with a different
    > hierarchy, ExceptionWithDefaultHanlder or some such.


    Thread.setDefaultUncaughtExceptionHandler ?

    Arne
     
    Arne Vajhøj, May 31, 2008
    #5
  6. Kenneth P. Turvey wrote:
    > On Fri, 30 May 2008 20:52:01 -0400, Arne Vajhøj wrote:
    >> Thread.setDefaultUncaughtExceptionHandler ?

    >
    > Not exactly what I'm looking for. More along the lines of setting a
    > default method of handling an exception if there isn't something to catch
    > it. So we could happily ignore the ThreadInterruptedExeption and such.
    >
    > It would require a new hierarchy. Maybe DefaultedException.


    I would say that method does that.

    What do you need additionally ? The ability to only
    use it for specified exceptions ? The ability to
    ignore the exception (not unroll the call stack) ?

    Arne
     
    Arne Vajhøj, May 31, 2008
    #6
  7. Volker Borchert

    Arne Vajhøj Guest

    Tim Smith wrote:
    > In article <48400854$0$16916$>,
    > "Kenneth P. Turvey" <> wrote:
    >> On Fri, 30 May 2008 14:22:21 +0100, Tom Anderson wrote:
    >>> Maybe. If the semantics of Desktop.moveToTrash(File) are that it moves
    >>> something to the trash, then is a permanent delete a good fallback? If i
    >>> let a user put things in the trash, but actually delete them, then later
    >>> he finds out his files are gone forever, am i not guilty of misleading
    >>> him?

    >> An exception might be best I suppose.
    >>
    >> Actually maybe not. 99.9% of the time the exception will be handled by
    >> deleting the file.

    >
    > If the system does not normally use a trash system, then the user will
    > expect files they delete to go away right away, so that is the right
    > behavior. Thus, there is no need for an exception.


    You are assuming that the app does not tell the user otherwise.

    What with a button with the text "Delete file so that it can be
    recovered" ?

    > It would probably make the most sense for this to be part of File,
    > though: File.deleteForUser(). This would mean that the delete decision
    > was made by a user, not the program, and so *if* the system normally
    > uses some mechanism to protect the user against accidents, it should be
    > used now.


    They have already started putting the useful available on most common
    platform in the Desktop class.

    I think they should put this there as well.

    File is supposed to be very general.

    Arne
     
    Arne Vajhøj, Jun 1, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tommy

    asp.net controls are trash

    Tommy, Nov 11, 2003, in forum: ASP .Net
    Replies:
    11
    Views:
    609
    S. Justin Gengo
    Nov 12, 2003
  2. Replies:
    0
    Views:
    2,885
  3. cppaddict

    Can Iterators Trash The Heap?

    cppaddict, Aug 27, 2004, in forum: C++
    Replies:
    7
    Views:
    339
    Old Wolf
    Aug 29, 2004
  4. Andrew Thompson

    Re: Trash Can and Sun

    Andrew Thompson, May 26, 2008, in forum: Java
    Replies:
    7
    Views:
    448
    Andrew Thompson
    May 28, 2008
  5. Roedy Green

    Re: Trash Can and Sun

    Roedy Green, May 27, 2008, in forum: Java
    Replies:
    1
    Views:
    416
    Arne Vajhøj
    May 28, 2008
Loading...

Share This Page