private void readFile(File file) throws IOException { FileInputStream stream = null; stream = new FileInputStream(file); DataInputStream sysin = new DataInputStream(stream); String line = null; while ((line = sysin.readLine()) != null) { if (line.trim().equals("")) { continue; } System.out.println(line); } }
public void write(String filePath) throws IOException { File file = new File(filePath); if (!file.exists()) file.createNewFile(); FileOutputStream out = new FileOutputStream(file, false); String data = "aa\nbb"; out.write(data.toString().getBytes("utf-8")); ParsePclntResult obj = new ParsePclntResult(); }
private void cleanupRecursive(File file) { try { if (file.isDirectory()) { for (File child : file.listFiles()) { cleanupRecursive(child); } if (file.listFiles().length == 0) { file.delete(); } } else { if (file.getName().endsWith(".xls")) { file.delete(); } } } catch (Exception e) { System.out.println(e.getMessage() + "\nFile:" + file.getAbsolutePath()); } }
原文地址:http://blog.csdn.net/tiankefeng19850520/article/details/45274139