How can I spawn items into a chest, using Command Blocks?

Like the title states, I want to be able to spawn items using a command block, and have them placed into a chest.
And I don't want to replace the chest, I want it to just add my block into the chest.
Best Answer
Do
/replaceitem block <x> <y> <z> <slot (if you want to fill the 9th slot of an ender chest with something, change this to slot.enderchest.9)> <item> [data] [dataValue]
Pictures about "How can I spawn items into a chest, using Command Blocks?"



How do you make items spawn in a chest in Minecraft?
Choose from either the /give or /setblock command. When you have finished adding items to your chest, click on the Generate Command button and then copy/paste the command into Minecraft. If the command is longer than 256 characters, you will need to paste the command into a command block.Summon items into Minecraft with 1 simple command item generators.
More answers regarding how can I spawn items into a chest, using Command Blocks?
Answer 2
This should work:
/setblock ~ ~ ~ chest 5
or if it doesnt work try chest 2 {Items:[{id:<item>,Slot:<slot>,Count:<how many>,Damage:0s}]}
Answer 3
Why not just clone a hopper with a certain item that will point to the chest. The only problem I think is you can't really time it well (to me with this idea I filled the chest with one item per tick)
Answer 4
This might be a little roundabout way of looking at it but you could have your chest that already has items in it and attach a hopper that will feed item into it that chest. Then generate a command that will spawn a chest and feed those items of the spawned chest into your untouched chest with the hopper.
here is a link that will auto generate you a command that will generate a chest with custom items in it. With a Example:
/setblock ~1 ~ ~ chest 0 replace { Items: [ { id: "stone", Slot: 4, Count: 1 } ] }
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Anete Lusina, Sora Shimazaki, Anete Lusina, Vanessa Loring