summaryrefslogtreecommitdiff
path: root/plugins/InspectionGadgets/test/com/siyeh/igtest/internationalization/implicit_default_charset_usage/ImplicitDefaultCharsetUsage.java
blob: 17dd59eadf7afd631bca3932e5808e190e7cb4e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.siyeh.igtest.internationalization.implicit_default_charset_usage;

import java.io.*;
import java.util.ArrayList;
import java.util.Formatter;
import java.util.Locale;
import java.util.Scanner;

class ImplicitDefaultCharsetUsage {

  void f() throws IOException {
    final byte[] bytes = "asdf".<warning descr="Call to 'getBytes()' uses the platform's default charset">getBytes</warning>();
    "asdf".getBytes("");
    new String();
    new String("asdfas");
    new String(new byte[10], "asdf");
    new <warning descr="'new String()' call uses the platform's default charset">String</warning>(new byte[10]);
    new <warning descr="'new String()' call uses the platform's default charset">String</warning>(new byte[10], 1, 9);
    new <warning descr="'new InputStreamReader()' call uses the platform's default charset">InputStreamReader</warning>(null);
    new InputStreamReader(null, "utf-8");
    new <warning descr="'new OutputStreamWriter()' call uses the platform's default charset">OutputStreamWriter</warning>(null);
    new OutputStreamWriter(null, "utf-8");
    new <warning descr="'new FileReader()' call uses the platform's default charset">FileReader</warning>("asdf");
    new <warning descr="'new FileWriter()' call uses the platform's default charset">FileWriter</warning>((String)null);
    new <warning descr="'new PrintStream()' call uses the platform's default charset">PrintStream</warning>((OutputStream)null);
    new PrintStream("filename", "utf-8");
    new PrintStream("filename");
    new PrintWriter((Writer)null);
    new PrintWriter("filename", "utf-8");
    new <warning descr="'new PrintWriter()' call uses the platform's default charset">PrintWriter</warning>("filename");
    new <warning descr="'new Formatter()' call uses the platform's default charset">Formatter</warning>(new FileOutputStream("null"));
    new Formatter(new FileOutputStream("null"), "utf-8");
    new Formatter(new FileOutputStream("null"), "utf-8", Locale.getDefault());
    new Formatter(System.out);
    new <warning descr="'new Scanner()' call uses the platform's default charset">Scanner</warning>(new FileInputStream("null"));
    new Scanner(new FileInputStream("null"), "utf-8");
    new Scanner("string input");
    new ArrayList(10);
  }
}