mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-08 09:36:04 +00:00
Remember the encoding of the log file so that we can display the log file in the right encoding later.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@12723 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
0e2a44955b
commit
824764b576
6 files changed
+75
-7
No files matched your search
@@ -20,7 +20,6 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -28,6 +27,8 @@ import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.io.PrintStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.net.URI;
|
||||
@@ -50,6 +51,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Various utility methods that don't have more proper home.
|
||||
@@ -131,12 +133,16 @@ public class Util {
|
||||
* Loads the contents of a file into a string.
|
||||
*/
|
||||
public static String loadFile(File logfile) throws IOException {
|
||||
return loadFile(logfile, Charset.defaultCharset());
|
||||
}
|
||||
|
||||
public static String loadFile(File logfile,Charset charset) throws IOException {
|
||||
if(!logfile.exists())
|
||||
return "";
|
||||
|
||||
StringBuffer str = new StringBuffer((int)logfile.length());
|
||||
|
||||
BufferedReader r = new BufferedReader(new FileReader(logfile));
|
||||
BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(logfile),charset));
|
||||
char[] buf = new char[1024];
|
||||
int len;
|
||||
while((len=r.read(buf,0,buf.length))>0)
|
||||
|
||||
Reference in new issue
Block a user