Example usage for java.io FileNotFoundException printStackTrace

List of usage examples for java.io FileNotFoundException printStackTrace

Introduction

In this page you can find the example usage for java.io FileNotFoundException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:Main.java

public static void writeBitmapToDisk(String url, Bitmap bmp, Context ctx, CompressFormat format) {
    FileOutputStream fos;/*from w  w w.  j ava2s .c  om*/
    String fileName = constructFileName(url);
    try {
        if (bmp != null) {
            fos = new FileOutputStream(new File(ctx.getCacheDir(), fileName));
            bmp.compress(format, 75, fos);
            fos.close();
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static String saveFile(Bitmap bm, String dirPath, String fileName, int scale) {
    File dirFile = new File(dirPath);
    if (!dirFile.exists()) {
        dirFile.mkdirs();/*  w  ww.ja va 2s.com*/
    }
    File myCaptureFile = new File(dirPath + fileName);
    try {
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
        bm.compress(Bitmap.CompressFormat.JPEG, scale, bos);
        bos.flush();
        bos.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return dirPath + fileName;
}

From source file:Main.java

public static Bitmap getBitmapByFile(File file) {
    FileInputStream fis = null;/*from   w w  w  . ja va  2 s .  c om*/
    Bitmap bitmap = null;
    try {
        fis = new FileInputStream(file);
        bitmap = BitmapFactory.decodeStream(fis);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (OutOfMemoryError e) {
        e.printStackTrace();
    } finally {
        try {
            fis.close();
        } catch (Exception e) {
        }
    }
    return bitmap;
}

From source file:Main.java

public static Bitmap getBitmap(Context context, String fileName) {
    FileInputStream fis = null;/* ww w .j  a v  a2  s  . c om*/
    Bitmap bitmap = null;
    try {
        fis = context.openFileInput(fileName);
        bitmap = BitmapFactory.decodeStream(fis);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (OutOfMemoryError e) {
        e.printStackTrace();
    } finally {
        try {
            fis.close();
        } catch (Exception e) {
        }
    }
    return bitmap;
}

From source file:Main.java

public static Boolean copyFileToSd(InputStream assetFile, File sdFile) {
    boolean flags = false;
    try {/* www . j a  va2  s.  co m*/
        FileOutputStream fos = new FileOutputStream(sdFile);
        byte[] buffer = new byte[1024];
        int count;
        while ((count = assetFile.read(buffer)) > 0) {
            fos.write(buffer, 0, count);
        }
        flags = true;
        fos.close();
        assetFile.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return flags;
}

From source file:Main.java

public static void writeString(Context context, String content, String path) {
    try {//w  ww.  ja va  2s  . c o m
        FileOutputStream fos = context.openFileOutput(path, Context.MODE_PRIVATE);
        PrintStream ps = new PrintStream(fos);
        ps.print(content);
        ps.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static Object convertXmlPathToObject(String xmlPath, Class clazz) {
    Object object = null;/*  ww w . j  av  a2  s.c o m*/
    try {
        JAXBContext context = JAXBContext.newInstance(clazz);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        FileReader xmlReader = null;
        try {
            xmlReader = new FileReader(xmlPath);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        object = unmarshaller.unmarshal(xmlReader);
    } catch (JAXBException e) {
        e.printStackTrace();
    }
    return object;
}

From source file:Main.java

public static void createCacheFileFromStream(Bitmap bitmap, String path) {
    File file = new File(path);
    OutputStream out = null;/*from   w  w  w . j  a v  a2s .  co  m*/
    try {
        out = new FileOutputStream(file);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } finally {
        try {
            if (out != null) {
                out.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:Main.java

public static void saveSerializableObjectToFile(Object object, FileOutputStream fileOut) {
    ObjectOutputStream out = null;
    try {/* w w  w .j a v a  2  s  . c om*/
        out = new ObjectOutputStream(fileOut);
        out.writeObject(object);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (out != null) {
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:de.randi2.ui.integration.AbstractUITest.java

@BeforeClass
public static void loadTestProperties() {
    try {/*from  w  ww . j  av a  2  s  . com*/
        testData.load((new ClassPathResource("testData.properties").getInputStream()));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}