Here you can find the source of readFile(String absoluteFileName)
Parameter | Description |
---|---|
absoluteFileName | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static String readFile(String absoluteFileName) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; public class Main { /**// w w w.ja v a 2 s. c o m * Fills the contents of the file given to a String * * @param absoluteFileName * @return * @throws IOException */ public static String readFile(String absoluteFileName) throws IOException { File file = new File(absoluteFileName); byte buffer[] = null; RandomAccessFile raf = null; try { raf = new RandomAccessFile(absoluteFileName, "r"); int fileSize = (int) file.length(); buffer = new byte[fileSize]; raf.read(buffer, 0, fileSize); } finally { if (raf != null) raf.close(); } return new String(buffer, "ISO-8859-9"); } }