| | |
| | | |
| | | |
| | | public List<Inhalt> collectFiles(String requestUrl, String contextPath, |
| | | String relativePath, int maxTiefe, int maxAnzahl, long length) { |
| | | String relativePath, int maxTiefe, int maxAnzahl, int length) { |
| | | Bild bild = new Bild(); |
| | | //WbxUtils wu = new WbxUtils(); |
| | | String basis = getJNDIParameter(WBX_FILE_BASE, WbxUtils.EMPTY_STRING); |
| | |
| | | cont.setIsHidden(beitrag.isHidden()); |
| | | cont.setLastModified(beitrag.lastModified()); |
| | | cont.setLength(beitrag.length()); |
| | | if(length > 0) { |
| | | cont.setAbst(getFileContent(beitrag, length)); |
| | | } |
| | | |
| | | /* |
| | | den 'https://..'-Teil bis vor dem |
| | |
| | | return files; |
| | | } |
| | | |
| | | private String getFileContent(File file, long len) { |
| | | private String getFileContent(File file, int 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); |
| | | char[] buf = new char[1]; |
| | | FileReader fr = new FileReader(file); |
| | | int bytesRead = fr.read(buf); |
| | | int read = 0; |
| | | while(bytesRead > -1 && read < len) { |
| | | read += bytesRead; |
| | | readBuffer.append(buf); |
| | | bytesRead = fr.read(buf); |
| | | } |
| | | |
| | | readBuffer.append(buf); |
| | | fr.close(); |
| | | logger.fine("read: " + read + ", readBuffer.len: " + readBuffer.length()); |
| | | return readBuffer.toString(); |
| | | } catch (Exception ex) { |
| | | Logger.getLogger(WbxUtils.class.getName()).log(Level.SEVERE, null, ex); |
| | | logger.log(Level.SEVERE, ex.getMessage(), ex); |
| | | return EMPTY_STRING; |
| | | } |
| | | } |