@@ -0,0 +1,2368 @@
+/**%0D%0A * Copyright (c) 2008-2010 Andrey Somov%0D%0A *%0D%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0D%0A * you may not use this file except in compliance with the License.%0D%0A * You may obtain a copy of the License at%0D%0A *%0D%0A *     http://www.apache.org/licenses/LICENSE-2.0%0D%0A *%0D%0A * Unless required by applicable law or agreed to in writing, software%0D%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0D%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0D%0A * See the License for the specific language governing permissions and%0D%0A * limitations under the License.%0D%0A */%0D%0A%0D%0Apackage org.yaml.snakeyaml.issues.issue46;%0D%0A%0D%0Aimport java.io.File;%0D%0Aimport java.io.IOException;%0D%0Aimport java.util.HashMap;%0D%0Aimport java.util.Map;%0D%0A%0D%0Aimport junit.framework.TestCase;%0D%0A%0D%0Aimport org.yaml.snakeyaml.Dumper;%0D%0Aimport org.yaml.snakeyaml.DumperOptions;%0D%0Aimport org.yaml.snakeyaml.Yaml;%0D%0Aimport org.yaml.snakeyaml.nodes.Node;%0D%0Aimport org.yaml.snakeyaml.nodes.Tag;%0D%0Aimport org.yaml.snakeyaml.representer.Represent;%0D%0Aimport org.yaml.snakeyaml.representer.Representer;%0D%0A%0D%0A/**%0D%0A * Issue 46: Dump a java.io.File object%0D%0A */%0D%0Apublic class FileTest extends TestCase %7B%0D%0A    @SuppressWarnings(%22unchecked%22)%0D%0A    public void test() throws IOException %7B%0D%0A        File file = new File(%22src/test/resources/examples/list-bean-1.yaml%22);%0D%0A        assertTrue(file.exists());%0D%0A        Yaml yaml = new Yaml(new Dumper(new MyRepresenter(), new DumperOptions()));%0D%0A        Map%3CString, File%3E map = new HashMap%3CString, File%3E();%0D%0A        map.put(%22one%22, file);%0D%0A        String output = yaml.dump(map);%0D%0A        // System.out.println(output);%0D%0A        Map%3CString, File%3E parsed = (Map%3CString, File%3E) yaml.load(output);%0D%0A        File file2 = parsed.get(%22one%22);%0D%0A        assertTrue(file2.getAbsolutePath(), file2.getAbsolutePath().endsWith(%22list-bean-1.yaml%22));%0D%0A    %7D%0D%0A%0D%0A    public class MyRepresenter extends Representer %7B%0D%0A        public MyRepresenter() %7B%0D%0A            this.representers.put(File.class, new FileRepresenter());%0D%0A        %7D%0D%0A%0D%0A        public class FileRepresenter implements Represent %7B%0D%0A            public Node representData(Object data) %7B%0D%0A                File file = (File) data;%0D%0A                Node scalar = representScalar(new Tag(%22!!java.io.File%22), file.getAbsolutePath());%0D%0A                return scalar;%0D%0A            %7D%0D%0A        %7D%0D%0A    %7D%0D%0A%7D%0D%0A

add example for issue 46: Dump a java.io.File object