@@ -0,0 +1,2229 @@
+//snippet-sourcedescription:%5BPresignedSwing.java demonstrates how to a presigned object using a Java Swing app.%5D%0A//snippet-keyword:%5BAWS SDK for Java v2%5D%0A//snippet-keyword:%5BCode Sample%5D%0A//snippet-service:%5BAmazon S3%5D%0A//snippet-sourcetype:%5Bfull-example%5D%0A//snippet-sourcedate:%5B12/15/2021%5D%0A//snippet-sourceauthor:%5Bscmacdon-aws%5D%0A%0A/*%0A   Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.%0A   SPDX-License-Identifier: Apache-2.0%0A*/%0A%0Apackage com.example.s3;%0A%0Aimport javax.swing.*;%0Aimport java.awt.event.*;%0Aimport java.io.File;%0Aimport java.io.FileOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.net.URL;%0A%0Aclass Swing implements ActionListener %7B%0A    JFrame frame=new JFrame();%0A    JButton button=new JButton(%22Get Presigned Amazon S3 Object%22);%0A%0A    Swing()%7B%0A        prepareGUI();%0A        buttonProperties();%0A    %7D%0A%0A    public void prepareGUI()%7B%0A        frame.setTitle(%22My Window%22);%0A        frame.getContentPane().setLayout(null);%0A        frame.setVisible(true);%0A        frame.setBounds(200,200,400,400);%0A        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);%0A    %7D%0A    public void buttonProperties()%7B%0A        button.setBounds(130,200,200,100);%0A        frame.add(button);%0A        button.addActionListener(this);%0A    %7D%0A%0A    @Override%0A    public void actionPerformed(ActionEvent e) %7B%0A        //Get a presigned PDF from an Amazon S3 bucket.%0A        try %7B%0A            URL url  =  new URL(%22%3CSpecify a Presigned URL%3E%22) ;%0A            InputStream in = null;%0A            in = url.openStream();%0A            FileOutputStream fos = new FileOutputStream(new File(%22C:%5C%5CAWS%5C%5CyourFile2.txt%22));%0A            System.out.println(%22reading from resource and writing to file...%22);%0A            int length = -1;%0A            byte%5B%5D buffer = new byte%5B1024%5D;// buffer for portion of data from connection%0A            while ((length = in.read(buffer)) %3E -1) %7B%0A                fos.write(buffer, 0, length);%0A            %7D%0A            fos.close();%0A            in.close();%0A            System.out.println(%22File downloaded%22);%0A        %7D catch (IOException ex) %7B%0A            ex.printStackTrace();%0A        %7D%0A    %7D%0A%7D%0A%0Apublic class PresignedSwing %7B%0A    public static void main(String%5B%5D args)%0A    %7B%0A        new Swing();%0A    %7D%0A%7D%0A

Create PresignedSwing.java