How can I save the filtered Map and the relationed data in JOSM

I download a part of map and edit it with the tool filter in JOSM. Now I want to save the filtered map and the relationed data.How can I do it? I tried several times and always got the whole original data.

Without having tried that on my own in JOSM:

Filtering elements has only effects on their visibility.

If you want to get rid of them permanently, you have to delete in an extra step … then save your raw OSM data to harddisk.

But do NOT upload the data to the central OSM server if you only deleted elements for your very own purposes.

Zoom out, then use the selection tool to draw a box, and select everything in that area (note this will not select filtered objects).
Then use Edit - > Copy, then create a new layer, then Paste the objects into that layer. You can then save that layer as an .osm file (though as Stephan says, you should not upload this layer to openstreetmap.org).

Vclaw’s workflow will also eliminate the “not-copied”-elements from the dataset. In stephan75’s workflow the deleted elements will stay in the dataset, they will only get a flag like “visible=false”, which in OSM-Terms means “deleted”.

To not accidentialy mess up live OSM-Data, you could also use offline-tools like Osmfilter to remove content from your dataset.

Or you could use edit/purge instead of delete. Then they will only go away in your local copy.

Jo