• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.
8  *
9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 /*
24  * @test
25  * @bug 6609431
26  * @summary Test whether loading of a property value in a file ending with
27  *    a backslash works fine.
28  */
29 
30 package test.java.util.Properties;
31 
32 import java.io.File;
33 import java.io.FileReader;
34 import java.io.IOException;
35 import java.io.InputStream;
36 import java.io.InputStreamReader;
37 import java.io.Reader;
38 import java.util.Properties;
39 
40 public class Bug6609431 {
41     private static final String expected = "backslash";
42 
43     // Android-added: reading from resources, not local files.
inputStream()44     private static InputStream inputStream() {
45         return Bug6609431.class.getResourceAsStream("Bug6609431.properties");
46     }
47 
48 
main(String[] args)49     public static void main(String[] args) throws IOException {
50         // BEGIN Android-changed: readging from resources, not local files.
51         /*
52         try (FileReader fr =
53                 new FileReader(new File(System.getProperty("test.src", "."),
54                                         "Bug6609431.properties"))) {
55         */
56         try (Reader fr =
57                 new InputStreamReader(inputStream())) {
58         // END Android-changed: readging from resources, not local files.
59             Properties p = new Properties();
60             p.load(fr);
61             p.getProperty("a");
62             String val = p.getProperty("b");
63             if (!val.equals(expected)) {
64                 throw new RuntimeException("Value returned from the property" +
65                 " list was incorrect. Returned: '" + val +
66                 "', expected: '" + expected + "'");
67             }
68         }
69     }
70 }
71