From 27d922ec03686599f688e8bb0a64375a3d559129 Mon Sep 17 00:00:00 2001 From: ulrich <undisclosed> Date: Thu, 05 Apr 2018 06:20:54 +0000 Subject: [PATCH] file content (in Arbeit) --- src/de/uhilger/wbx/WbxUtils.java | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-) diff --git a/src/de/uhilger/wbx/WbxUtils.java b/src/de/uhilger/wbx/WbxUtils.java index 963b5bf..ff5dcf1 100644 --- a/src/de/uhilger/wbx/WbxUtils.java +++ b/src/de/uhilger/wbx/WbxUtils.java @@ -19,7 +19,12 @@ package de.uhilger.wbx; import de.uhilger.wbx.data.Inhalt; +import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -54,7 +59,7 @@ public List<Inhalt> collectFiles(String requestUrl, String contextPath, - String relativePath, int maxTiefe, int maxAnzahl) { + String relativePath, int maxTiefe, int maxAnzahl, long length) { Bild bild = new Bild(); //WbxUtils wu = new WbxUtils(); String basis = getJNDIParameter(WBX_FILE_BASE, WbxUtils.EMPTY_STRING); @@ -105,6 +110,28 @@ return files; } + private String getFileContent(File file, long len) { + try { + StringBuffer readBuffer = new StringBuffer(); + byte[] buf = new byte[1024]; + long read = 0; + FileInputStream fis = new FileInputStream(file); + int bytesRead = fis.read(buf); + read += bytesRead; + while(read < len) { + readBuffer.append(buf); + bytesRead = fis.read(buf); + read += bytesRead; + } + + readBuffer.append(buf); + return readBuffer.toString(); + } catch (Exception ex) { + Logger.getLogger(WbxUtils.class.getName()).log(Level.SEVERE, null, ex); + return EMPTY_STRING; + } + } + /** * Diese Methode funktioniert nur, wenn entweder ein Ordner uebergeben -- Gitblit v1.9.3