Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class Main { private static String codificacao = "UTF-8"; public static String pegaCabecalho(String nomeArq) { String cabecalho = ""; try { BufferedReader txtBuffer = new BufferedReader( new InputStreamReader(new FileInputStream(nomeArq), codificacao)); cabecalho = txtBuffer.readLine(); txtBuffer.close(); } catch (IOException e) { System.out.println("[ERROR] Erro ao buscar cabecalho do arquivo: " + nomeArq); System.exit(-1); } return cabecalho; } }