Example usage for java.io IOException toString

List of usage examples for java.io IOException toString

Introduction

In this page you can find the example usage for java.io IOException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:Main.java

public static void main(String[] args) {
    try {/* ww  w  .j av  a 2 s. c o  m*/
        char[] chars = new char[2];
        chars[0] = '\u4F60';
        chars[1] = '\u597D';
        String encoding = "GB18030";
        File textFile = new File("C:\\temp\\myFile.txt");
        OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(textFile), encoding);
        writer.write(chars);
        writer.close();
    } catch (IOException e) {
        System.out.println(e.toString());
    }
}

From source file:Main.java

public static void main(String[] arguments) {
    int[] data = { 137, 89, 82, 181, 50, 220, 103, 20, 0, 59 };
    try {//from www  .  j  av  a2 s.com
        FileOutputStream file = new FileOutputStream("pic.dat");
        for (int i = 0; i < data.length; i++)
            file.write(data[i]);
        file.close();
    } catch (IOException e) {
        System.out.println("Error - " + e.toString());
    }
}

From source file:Main.java

public static void main(String[] arguments) {
    try {//from   w  w w  . j a va2 s  .  c  om
        FileOutputStream file = new FileOutputStream("p.dat");
        BufferedOutputStream buff = new BufferedOutputStream(file);
        DataOutputStream data = new DataOutputStream(buff);

        for (int i = 0; i < 400; i++)
            data.writeInt(i);
        data.close();
    } catch (IOException e) {
        System.out.println("Error - " + e.toString());
    }
}

From source file:Main.java

public static void main(String[] args) {
    try {/*  www.  j a va2  s  .c  om*/
        char[] chars = new char[2];
        chars[0] = '\u4F60';
        chars[1] = '\u597D';
        String encoding = "GB18030";
        File textFile = new File("C:\\temp\\myFile.txt");
        PrintWriter writer = new PrintWriter(textFile, encoding);
        writer.write(chars);
        writer.close();

        // read back
        InputStreamReader reader = new InputStreamReader(new FileInputStream(textFile), encoding);
        char[] chars2 = new char[2];
        reader.read(chars2);
        System.out.print(chars2[0]);
        System.out.print(chars2[1]);
        reader.close();
    } catch (IOException e) {
        System.out.println(e.toString());
    }
}

From source file:SourceReader.java

public static void main(String[] arguments) {
    try {/*ww w . j  a  v  a2  s.c  o m*/
        FileReader file = new FileReader("SourceReader.java");
        BufferedReader buff = new BufferedReader(file);
        boolean eof = false;
        while (!eof) {
            String line = buff.readLine();
            if (line == null)
                eof = true;
            else
                System.out.println(line);
        }
        buff.close();
    } catch (IOException e) {
        System.out.println("Error - " + e.toString());
    }
}

From source file:org.jfree.chart.demo.MeterChartDemo4.java

public static void main(String args[]) {
    DefaultValueDataset defaultvaluedataset = new DefaultValueDataset(75D);
    MeterPlot meterplot = new MeterPlot(defaultvaluedataset);
    JFreeChart jfreechart = new JFreeChart("Scaled Image Test", meterplot);
    try {/*from  w  w  w. j  a  v a  2 s  . c  o m*/
        File file = new File("meterchart100.png");
        BufferedOutputStream bufferedoutputstream = new BufferedOutputStream(new FileOutputStream(file));
        java.awt.image.BufferedImage bufferedimage = jfreechart.createBufferedImage(200, 200, 400D, 400D, null);
        ChartUtilities.writeBufferedImageAsPNG(bufferedoutputstream, bufferedimage);
    } catch (IOException ioexception) {
        System.out.println(ioexception.toString());
    }
}

From source file:MainClass.java

public static void main(String[] args) {
    try {//from   w w w .  jav a  2  s.c  o m
        char[] chars = new char[2];
        chars[0] = '\u4F60';
        chars[1] = '\u597D';
        String encoding = "GB18030";
        File textFile = new File("C:\\temp\\myFile.txt");
        PrintWriter writer = new PrintWriter(textFile,

                encoding);
        writer.write(chars);
        writer.close();

        // read back
        InputStreamReader reader = new InputStreamReader(new FileInputStream(textFile), encoding);
        char[] chars2 = new char[2];
        reader.read(chars2);
        System.out.print(chars2[0]);
        System.out.print(chars2[1]);
        reader.close();
    } catch (IOException e) {
        System.out.println(e.toString());
    }
}

From source file:ByteReader.java

public static void main(String[] arguments) {
    try {//from w  ww  .  j  a v  a2s .  c  o  m
        FileInputStream file = new FileInputStream("class.dat");
        boolean eof = false;
        int count = 0;
        while (!eof) {
            int input = file.read();
            System.out.print(input + " ");
            if (input == -1)
                eof = true;
            else
                count++;
        }
        file.close();
        System.out.println("\nBytes read: " + count);
    } catch (IOException e) {
        System.out.println("Error - " + e.toString());
    }
}

From source file:PrimeReader.java

public static void main(String[] arguments) {
    try {/* www  .  j  a  va2  s .  c o m*/
        FileInputStream file = new FileInputStream("400primes.dat");
        BufferedInputStream buff = new BufferedInputStream(file);
        DataInputStream data = new DataInputStream(buff);

        try {
            while (true) {
                int in = data.readInt();
                System.out.print(in + " ");
            }
        } catch (EOFException eof) {
            buff.close();
        }
    } catch (IOException e) {
        System.out.println("Error - " + e.toString());
    }
}

From source file:PrimeWriter.java

public static void main(String[] arguments) {
    int[] primes = new int[400];
    int numPrimes = 0;

    int candidate = 2;
    while (numPrimes < 400) {
        primes[numPrimes] = candidate;//from  w  w w.j  av a  2 s . c  o  m
        numPrimes++;
        candidate++;
    }

    try {
        FileOutputStream file = new FileOutputStream("p.dat");
        BufferedOutputStream buff = new BufferedOutputStream(file);
        DataOutputStream data = new DataOutputStream(buff);

        for (int i = 0; i < 400; i++)
            data.writeInt(primes[i]);
        data.close();
    } catch (IOException e) {
        System.out.println("Error - " + e.toString());
    }
}