public void moveAllInstances( LearningMethod method, FeatureFunction divideFeature, ArrayList<Integer> divideFeatureIndexVector) throws MaltChainedException { if (method == null) { throw new LibException("The learning method cannot be found. "); } else if (divideFeature == null) { throw new LibException("The divide feature cannot be found. "); } try { final BufferedReader in = new BufferedReader(getInstanceInputStreamReader(".ins")); final BufferedWriter out = method.getInstanceWriter(); final StringBuilder sb = new StringBuilder(6); int l = in.read(); char c; int j = 0; while (true) { if (l == -1) { sb.setLength(0); break; } c = (char) l; l = in.read(); if (c == '\t') { if (divideFeatureIndexVector.contains(j - 1)) { out.write( Integer.toString( ((SingleFeatureValue) divideFeature.getFeatureValue()).getIndexCode())); out.write('\t'); } out.write(sb.toString()); j++; out.write('\t'); sb.setLength(0); } else if (c == '\n') { out.write(sb.toString()); if (divideFeatureIndexVector.contains(j - 1)) { out.write('\t'); out.write( Integer.toString( ((SingleFeatureValue) divideFeature.getFeatureValue()).getIndexCode())); } out.write('\n'); sb.setLength(0); method.increaseNumberOfInstances(); this.decreaseNumberOfInstances(); j = 0; } else { sb.append(c); } } in.close(); getFile(".ins").delete(); out.flush(); } catch (SecurityException e) { throw new LibException("The learner cannot remove the instance file. ", e); } catch (NullPointerException e) { throw new LibException("The instance file cannot be found. ", e); } catch (FileNotFoundException e) { throw new LibException("The instance file cannot be found. ", e); } catch (IOException e) { throw new LibException("The learner read from the instance file. ", e); } }