FileDocCategorySizeDatePackage
StreamConverter.javaAPI DocExample2058Tue Dec 12 18:57:36 GMT 2000None

StreamConverter

public class StreamConverter extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)


      String jaString  = 
         new String("\u65e5\u672c\u8a9e\u6587\u5b57\u5217");

      writeOutput(jaString);
      String inputString = readInput();
      String displayString = jaString + " " + inputString;
      new ShowString(displayString, "Conversion Demo");
   
static java.lang.StringreadInput()


      StringBuffer buffer = new StringBuffer();
      try {
          FileInputStream fis = new FileInputStream("test.txt");
          InputStreamReader isr = new InputStreamReader(fis, "UTF8");
          Reader in = new BufferedReader(isr);
          int ch;
          while ((ch = in.read()) > -1) {
             buffer.append((char)ch);
          }
          in.close();
          return buffer.toString();
      } catch (IOException e) {
          e.printStackTrace();
          return null;
      }
   
static voidwriteOutput(java.lang.String str)


       try {
           FileOutputStream fos = new FileOutputStream("test.txt");
           Writer out = new OutputStreamWriter(fos, "UTF8");
           out.write(str);
           out.close();
       } catch (IOException e) {
           e.printStackTrace();
       }