Here you can find the source of readFile(String sFileName)
Parameter | Description |
---|---|
String | - sFileName (nome file) |
public static StringBuffer readFile(String sFileName) throws IOException
//package com.java2s; import java.io.*; public class Main { /**/*from w ww . j a v a2s. c om*/ * Legge un file * * @param String - sFileName (nome file) * @return StringBuffer - contenuto del file */ public static StringBuffer readFile(String sFileName) throws IOException { int nI = 0; byte buf[] = new byte[4096]; StringBuffer sHold = new StringBuffer(); BufferedInputStream bfin = null; try { bfin = new BufferedInputStream(new FileInputStream(sFileName)); while ((nI = bfin.read(buf)) != -1) { if (nI != -1) sHold.append(new String(buf, 0, nI)); } bfin.close(); } catch (Exception e) { e.printStackTrace(); } return sHold; } }