1 package org.myoodb.jythonWeb; 25 26 public class ScriptDbImpl extends org.myoodb.collectable.CollectableDbImpl implements Script 27 { 28 public ScriptDbImpl() 29 { 30 } 31 32 public String getCode(String file) 33 { 34 try 35 { 36 java.io.File script = new java.io.File (file); 37 java.io.FileInputStream in = new java.io.FileInputStream (script); 38 39 int offset = 0; 40 int size = in.available(); 41 byte[] buffer = new byte[in.available()]; 42 43 while (offset < size) 44 { 45 int bytesRead = in.read(buffer, offset, (size - offset)); 46 if (bytesRead == -1) 47 { 48 break; 49 } 50 offset += bytesRead; 51 } 52 53 return new String (buffer); 54 } 55 catch (Exception e) 56 { 57 e.printStackTrace(); 58 return null; 59 } 60 } 61 } 62 | Popular Tags |