![]()
Ще използваме DataInputStream за да преобразуваме , съдържанието в байтове.
package com.mkyong.io; import java.io.DataInputStream; import java.io.FileInputStream; public class App{ public static void main (String args[]) { try{ DataInputStream dis = new DataInputStream ( new FileInputStream ("c:\\logging.log")); byte[] datainBytes = new byte[dis.available()]; dis.readFully(datainBytes); dis.close(); String content = new String(datainBytes, 0, datainBytes.length); System.out.println(content); }catch(Exception ex){ ex.printStackTrace(); } } }
Пример:
10:21:29,425 INFO Version:15 - Hibernate Annotations 3.3.0.GA 10:21:29,441 INFO Environment:509 - Hibernate 3.2.3 10:21:29,441 INFO Environment:542 - hibernate.properties not found 10:21:29,456 INFO Environment:676 - Bytecode provider name : cglib 10:21:29,456 INFO Environment:593 - using JDK 1.4 java.sql.Timestamp handling ............
Popularity: 1% [?]
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
RSS Feed
Twitter

януари 13th, 2010
admin
Posted in 
