I have a jar file which I need to replace a few classes from. The problem is that they're located in a directory with a name that is too long for both arch and windows to handle.
(So the layout inside the jar file contains directory's with impossibly long names)
I therefore can't physically create the same directory structure and use "jar uf modded.jar com/"
Is there any way/program/command/trick to get those files to end up and that location in that jar file?
You can use the java.util.zip package to read and write a zip file. Since the zip entry names are just strings, the file system's limit on name length is not an obstacle:
import java.io.InputStream;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Collection;
import java.util.ArrayList;
import java.util.Map;
import java.util.LinkedHashMap;
import java.util.Enumeration;
import java.util.Objects;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
import java.util.zip.ZipException;
public class ZipUpdater {
private static final Logger logger =
Logger.getLogger(ZipUpdater.class.getName());
private final Map<String, Path> changes;
public ZipUpdater(Map<String, Path> changes) {
this.changes = new LinkedHashMap<>(
Objects.requireNonNull(changes, "Change list cannot be null"));
}
public void update(Path zipFile)
throws IOException,
ZipException {
Objects.requireNonNull(zipFile, "Zip file cannot be null");
Map<String, Path> changesNeeded = new LinkedHashMap<>(changes);
Path newZipFilePath = Files.createTempFile(null, ".zip");
try (ZipFile oldZipFile = new ZipFile(zipFile.toFile());
ZipOutputStream newZipFile = new ZipOutputStream(
new BufferedOutputStream(
Files.newOutputStream(newZipFilePath)))) {
String comment = oldZipFile.getComment();
if (comment != null) {
newZipFile.setComment(comment);
}
Enumeration<? extends ZipEntry> oldEntries = oldZipFile.entries();
while (oldEntries.hasMoreElements()) {
ZipEntry entry = oldEntries.nextElement();
String entryName = entry.getName();
Path source = changesNeeded.remove(entryName);
if (source != null) {
ZipEntry newEntry = new ZipEntry(entryName);
newEntry.setMethod(entry.getMethod());
newEntry.setTime(entry.getTime());
newEntry.setComment(entry.getComment());
newEntry.setExtra(entry.getExtra());
newZipFile.putNextEntry(newEntry);
logger.log(Level.INFO,
"Replacing entry \"{0}\" with contents of file \"{1}\"",
new Object[] { entryName, source });
Files.copy(source, newZipFile);
} else {
ZipEntry newEntry = new ZipEntry(entry);
newZipFile.putNextEntry(newEntry);
logger.log(Level.FINE, "Copying entry {0}", entryName);
try (InputStream entryData = new BufferedInputStream(
oldZipFile.getInputStream(entry))) {
int b;
while ((b = entryData.read()) >= 0) {
newZipFile.write(b);
}
}
}
newZipFile.closeEntry();
}
}
if (!changesNeeded.isEmpty()) {
throw new IOException("The following entries were not found"
+ " in '" + zipFile + "': " + changesNeeded.keySet());
}
Files.move(zipFile, Paths.get(zipFile + ".old"),
StandardCopyOption.REPLACE_EXISTING);
Files.move(newZipFilePath, zipFile);
}
public static void main(String[] args)
throws IOException,
ZipException {
if (args.length < 3 || (args.length % 2) != 1 ||
args[0].equals("-?") ||
args[0].equalsIgnoreCase("-h") ||
args[0].equalsIgnoreCase("--help")) {
System.err.println("Usage:");
System.err.println(
"java " + ZipUpdater.class.getName() + " <zipfile>"
+ " <zip-entry> <replacement-file>"
+ " [ <zip-entry> <replacement-file> ] ...");
System.exit(2);
}
Path zipFile = Paths.get(args[0]);
int argCount = args.length;
Map<String, Path> changes = new LinkedHashMap<>(argCount / 2);
for (int i = 1; i < argCount; i += 2) {
String entry = args[i];
Path replacement = Paths.get(args[i + 1]);
changes.put(entry, replacement);
}
ZipUpdater updater = new ZipUpdater(changes);
updater.update(zipFile);
}
}
Related
I have a x.zip file with the following structure (zip in zip in zip):
x.zip
/y.zip
/z.zip
I want to know the list of files and directories in the root of the z.zip without any unpacking archives.
You can read zip file contents directly from another zip entry’s InputStream. Be warned, however, that this is known to be rather slow:
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipException;
import java.util.stream.Stream;
public class NestedZipReader {
public List<String> listEntries(ZipFile zipFile,
List<String> nestedZipFiles)
throws IOException {
if (nestedZipFiles.isEmpty()) {
try (Stream<? extends ZipEntry> entries = zipFile.stream()) {
return entries.map(ZipEntry::getName).toList();
}
} else {
String name = nestedZipFiles.get(0);
ZipEntry entry = zipFile.getEntry(name);
if (entry != null) {
try (ZipInputStream nested = new ZipInputStream(
zipFile.getInputStream(entry))) {
return listEntries(nested, nestedZipFiles, 1);
}
}
throw new IllegalArgumentException("Entry not found: " + name);
}
}
public List<String> listEntries(ZipInputStream zipFile,
List<String> nestedZipFiles)
throws IOException {
return listEntries(zipFile, nestedZipFiles, 0);
}
private List<String> listEntries(ZipInputStream zipFile,
List<String> nestedZipFiles,
int nestedZipFileIndex)
throws IOException {
int count = nestedZipFiles.size();
if (nestedZipFileIndex >= count) {
List<String> names = new ArrayList<>();
ZipEntry entry;
while ((entry = zipFile.getNextEntry()) != null) {
names.add(entry.getName());
}
return names;
} else {
String name = nestedZipFiles.get(nestedZipFileIndex);
ZipEntry entry;
while ((entry = zipFile.getNextEntry()) != null) {
if (entry.getName().equals(name)) {
try (ZipInputStream nested = new ZipInputStream(zipFile)) {
return listEntries(
nested, nestedZipFiles, nestedZipFileIndex + 1);
}
}
}
throw new IllegalArgumentException("Entry not found: "
+ String.join(" => ",
nestedZipFiles.subList(0, nestedZipFileIndex + 1)));
}
}
public static void main(String[] args)
throws ZipException,
IOException {
NestedZipReader reader = new NestedZipReader();
List<String> entries;
try (ZipFile zipFile = new ZipFile(args[0])) {
entries = reader.listEntries(zipFile,
Arrays.asList(args).subList(1, args.length));
}
System.out.printf("%,d entries:%n%n", entries.size());
for (String entry : entries) {
System.out.println(entry);
}
}
}
Since Server A and server B doesn't have SFTP, and I am try to implement a web service on Server B, that takes the file on Server A and process it. I tried using Spring boot to do this, like save the file first, and the process. But this way it seems like async, which means when the code try to process the file, the file is not ready yet, (confirm when I print the file location, it return null). What is the good way to handle this?
Current Code I have for the controller is following:
package com.example.filedemo.controller;
import com.example.filedemo.payload.UploadFileResponse;
import com.example.filedemo.service.FileStorageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import javax.servlet.http.HttpServletRequest;
import javax.xml.ws.Response;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
#RestController
public class FileController {
private static final Logger logger = LoggerFactory.getLogger(FileController.class);
private static final String PYTHON_FILE = "V:/speechRecognition/audio_transcribe.py";
#Autowired
private FileStorageService fileStorageService;
#PostMapping("/uploadFile")
public UploadFileResponse uploadFile(#RequestParam("file") MultipartFile file) {
String fileName = fileStorageService.storeFile(file);
String fileDownloadUri =
ServletUriComponentsBuilder.fromCurrentContextPath().path("/downloadFile/").path(fileName).toUriString();
return new UploadFileResponse(fileName, fileDownloadUri, file.getContentType(), file.getSize());
}
#PostMapping("/processFile")
public ResponseEntity<String> processFile(#RequestParam("file") MultipartFile file) throws IOException {
String filename = uploadFile(file).getFileName();
File actualFile = new File("E:\\Audio\\uploads\\" + filename);
String fetching = "python " + PYTHON_FILE + " " + actualFile.getAbsolutePath();
String[] command = new String[] {"cmd.exe", "/c", fetching};
Process p = Runtime.getRuntime().exec(command);
String pythonPath = System.getProperty("PYTHON_PATH");
System.out.println("pythonPath is " + pythonPath);
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String ret = in.readLine();
System.out.println(ret);
return new ResponseEntity<String>("Success", HttpStatus.OK);
}
}
FileStorageService.java
package com.example.filedemo.service;
import com.example.filedemo.exception.FileStorageException;
import com.example.filedemo.exception.MyFileNotFoundException;
import com.example.filedemo.property.FileStorageProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.net.MalformedURLException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
#Service
public class FileStorageService {
private final Path fileStorageLocation;
#Autowired
public FileStorageService(FileStorageProperties fileStorageProperties) {
this.fileStorageLocation = Paths.get(fileStorageProperties.getUploadDir())
.toAbsolutePath().normalize();
try {
Files.createDirectories(this.fileStorageLocation);
} catch (Exception ex) {
throw new FileStorageException("Could not create the directory where the uploaded files will be stored.", ex);
}
}
public String storeFile(MultipartFile file) {
// Normalize file name
String fileName = StringUtils.cleanPath(file.getOriginalFilename());
try {
// Check if the file's name contains invalid characters
if(fileName.contains("..")) {
throw new FileStorageException("Sorry! Filename contains invalid path sequence " + fileName);
}
// Copy file to the target location (Replacing existing file with the same name)
Path targetLocation = this.fileStorageLocation.resolve(fileName);
long numberOfByte = Files.copy(file.getInputStream(), targetLocation, StandardCopyOption.REPLACE_EXISTING);
System.out.println("Copy byte " + numberOfByte);
return fileName;
} catch (IOException ex) {
throw new FileStorageException("Could not store file " + fileName + ". Please try again!", ex);
}
}
public Resource loadFileAsResource(String fileName) {
try {
Path filePath = this.fileStorageLocation.resolve(fileName).normalize();
Resource resource = new UrlResource(filePath.toUri());
if(resource.exists()) {
return resource;
} else {
throw new MyFileNotFoundException("File not found " + fileName);
}
} catch (MalformedURLException ex) {
throw new MyFileNotFoundException("File not found " + fileName, ex);
}
}
}
UploadFileResponse
package com.example.filedemo.payload;
public class UploadFileResponse {
private String fileName;
private String fileDownloadUri;
private String fileType;
private long size;
public UploadFileResponse(String fileName, String fileDownloadUri, String fileType, long size) {
this.fileName = fileName;
this.fileDownloadUri = fileDownloadUri;
this.fileType = fileType;
this.size = size;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getFileDownloadUri() {
return fileDownloadUri;
}
public void setFileDownloadUri(String fileDownloadUri) {
this.fileDownloadUri = fileDownloadUri;
}
public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
public long getSize() {
return size;
}
public void setSize(long size) {
this.size = size;
}
}
I would recommend storing the file in the database, then operating on it from there. Obviously, be careful the file size doesn't overrun the column size.
If your operations require an actual file on disk (rather than, say, a stream of bytes), then you could create a sync service that polls the database for new files and saves a copy on the local disk when found. Then your processing code can use the local disk file handle.
I have made a thread in java which continuously checks the recent items in the windows after a time interval of 1 hour and make a .csv file of all of the recent items. Moreover i have accesstime and folder location of all of the files in the recent items. Now what i am trying to do is as recent items continuously update itself so if there is a new file in the recent item it should append at the end of that already made csv file but i am stuck here and have no idea how to do that kindly help me My code is here
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package record;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import static java.sql.DriverManager.println;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import sun.awt.shell.ShellFolder;
/**
*
* #author zeeshan
*/
public class Record
{
static String user=System.getProperty("user.name");
static String path1="C:\\Users\\"+user+"\\AppData\\Roaming\\Microsoft\\Windows\\Recent\\";
static String path2="C:\\Users\\Fa16Rcs028\\Dropbox\\Spring 17\\Special Topics In HCI\\Sir Aimal Project\\output.csv";
static PrintWriter pw;
static StringBuilder sb = new StringBuilder();
public void createcsv()throws IOException
{
File directory = new File(path1);
File[] fList = directory.listFiles();
pw = new PrintWriter(new File(path2));
sb.append("File/Folder Name");
sb.append(',');
sb.append("Access Time");
sb.append(',');
sb.append("File Location");
sb.append('\n');
for (int i=0;i<fList.length;i++)
{
String filename=fList[i].getName();
String actualfilename=filename.replace(".lnk", "");
ShellFolder sf = ShellFolder.getShellFolder(fList[i]);
ShellFolder target = sf.getLinkLocation();
if (target != null)
{
Path p = Paths.get(path1+filename);
BasicFileAttributes view= Files.getFileAttributeView(p, BasicFileAttributeView.class).readAttributes();
FileTime fileTime=view.creationTime();
sb.append(actualfilename);
sb.append(',');
sb.append(new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format((fileTime.toMillis())));
sb.append(',');
sb.append(target.getAbsolutePath());
sb.append('\n');
}
}
pw.write(sb.toString());
pw.close();
}
public static class maintainrecord extends Thread
{
#Override
public void run()
{
File directory = new File(path1);
File[] fList = directory.listFiles();
for (File fList1 : fList) {
try {
String filename = fList1.getName();
String actualfilename=filename.replace(".lnk", "");
Path p = Paths.get(path1+filename);
BasicFileAttributes view= Files.getFileAttributeView(p, BasicFileAttributeView.class).readAttributes();
FileTime fileTime=view.creationTime();
String time=new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format((fileTime.toMillis())).toString();
String line = "";
String cvsSplitBy = ",";
try (BufferedReader br = new BufferedReader(new FileReader(path2)))
{
while ((line = br.readLine()) != null)
{
String[] record = line.split(cvsSplitBy);
String name=record[0];
String checktime=record[1];
if(actualfilename.equals(name) && !time.equals(checktime))
{
br.close();
pw = new PrintWriter(new File(path2));
sb.append(actualfilename);
sb.append(',');
sb.append(actualfilename);
sb.append(',');
}
}
}
}catch (IOException ex)
{
Logger.getLogger(Record.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
public static void main(String[] args) throws IOException
{
Record r=new Record();
r.createcsv();
Thread zeeshan=new Thread(new maintainrecord());
zeeshan.start();
Thread.sleep(600000);
}
}
I was making a pretty simple jar to unzip a zip and run the jar that was inside of it. The problem I've run into is that it doesn't do anything at all.
This is the main, and only class file for the jar. The manifest does point correctly to it, and it loads without errors.
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.BufferedOutputStream;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import static java.lang.Integer.parseInt;
import java.net.URLConnection;
import java.net.URL;
import java.util.zip.ZipFile;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.Enumeration;
import sign.signlink;
import java.nio.file.*;
import java.io.FileReader;
public class ClientUpdater {
private String fileToExtractNew = "/client.zip";
private String getJarDir() throws FileNotFoundException, IOException{
String linebuf="",verStr="";
FileInputStream fis = new FileInputStream("/runLocationURL.txt");
BufferedReader br= new BufferedReader(new InputStreamReader(fis));
while ((linebuf = br.readLine()) != null) {
verStr = linebuf;
}
return verStr;
}
public static void main(String[] args) {
System.out.println("start");
}
private void unZip() {
System.out.println("unzipping");
try {
ZipEntry zipEntry;
//client
BufferedInputStream bufferedInputStreamNew = new BufferedInputStream(new FileInputStream(this.fileToExtractNew));
ZipInputStream zipInputStreamNew = new ZipInputStream(bufferedInputStreamNew);
//client
while ((zipEntry = zipInputStreamNew.getNextEntry()) != null) {
String stringNew = zipEntry.getName();
File fileNew = new File(this.getJarDir() + File.separator + stringNew);
if (zipEntry.isDirectory()) {
new File(this.getJarDir() + zipEntry.getName()).mkdirs();
continue;
}
if (zipEntry.getName().equals(this.fileToExtractNew)) {
this.unzipNew(zipInputStreamNew, this.fileToExtractNew);
break;
}
new File(fileNew.getParent()).mkdirs();
this.unzipNew(zipInputStreamNew, this.getJarDir() + zipEntry.getName());
}
zipInputStreamNew.close();
}
catch (Exception var1_2) {
var1_2.printStackTrace();
}
}
private void unzipNew(ZipInputStream zipInputStreamNew, String stringNew) throws IOException {
System.out.println("unzipping new");
FileOutputStream fileOutputStreamNew = new FileOutputStream(stringNew);
byte[] arrby = new byte[4024];
int n = 0;
while ((n = zipInputStreamNew.read(arrby)) != -1) {
fileOutputStreamNew.write(arrby, 0, n);
}
fileOutputStreamNew.close();
Runtime.getRuntime().exec("java -jar " + getJarDir() + "/Project Pk Client.jar");
System.exit(0);
}
}
It shows the "Start" message, but not the other 2, so it never reaches those methods. Is it because they aren't being called? I'm still learning Java.
You actually have to call your other methods from main. Right now, all you are telling the computer to do is print start and then exit. Functions do not get called simply by existing.
It seems based on a quick glance that you just need to add unzip(); to your main function, right after the System.out.println line.
To do this, you need to say that those other methods are static, so you need to say private static void unZip() instead of private void unZip(). Do this for your other methods too.
import java.io.*;
import static java.lang.Integer.parseInt;
import java.net.URLConnection;
import java.net.URL;
import java.util.zip.ZipFile;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.Enumeration;
import sign.signlink;
import java.nio.file.*;
public class ClientUpdater {
private String fileToExtractNew = "/client.zip";
private static String getJarDir() throws FileNotFoundException, IOException{
String linebuf="",verStr="";
FileInputStream fis = new FileInputStream("/runLocationURL.txt");
BufferedReader br= new BufferedReader(new InputStreamReader(fis));
while ((linebuf = br.readLine()) != null) {
verStr = linebuf;
}
return verStr;
}
public static void main(String[] args) {
System.out.println("start");
unZip();
}
private static void unZip() {
System.out.println("unzipping");
try {
ZipEntry zipEntry;
//client
BufferedInputStream bufferedInputStreamNew = new BufferedInputStream(new FileInputStream(this.fileToExtractNew));
ZipInputStream zipInputStreamNew = new ZipInputStream(bufferedInputStreamNew);
//client
while ((zipEntry = zipInputStreamNew.getNextEntry()) != null) {
String stringNew = zipEntry.getName();
File fileNew = new File(this.getJarDir() + File.separator + stringNew);
if (zipEntry.isDirectory()) {
new File(this.getJarDir() + zipEntry.getName()).mkdirs();
continue;
}
if (zipEntry.getName().equals(this.fileToExtractNew)) {
this.unzipNew(zipInputStreamNew, this.fileToExtractNew);
break;
}
new File(fileNew.getParent()).mkdirs();
this.unzipNew(zipInputStreamNew, this.getJarDir() + zipEntry.getName());
}
zipInputStreamNew.close();
}
catch (Exception var1_2) {
var1_2.printStackTrace();
}
}
private static void unzipNew(ZipInputStream zipInputStreamNew, String stringNew) throws IOException {
System.out.println("unzipping new");
FileOutputStream fileOutputStreamNew = new FileOutputStream(stringNew);
byte[] arrby = new byte[4024];
int n = 0;
while ((n = zipInputStreamNew.read(arrby)) != -1) {
fileOutputStreamNew.write(arrby, 0, n);
}
fileOutputStreamNew.close();
Runtime.getRuntime().exec("java -jar " + getJarDir() + "/Project Pk Client.jar");
System.exit(0);
}
}
I am not able to get properties from an ontology file. I am new to ontology and apache jena. And also I am not able to use 'getProperty' command in proper way.
Till these code I am able to get classes but I don't know how to use 'getProperty','listObjectsOfProperty' command to get properties.
package onto1;
import java.io.InputStream;
import org.semarglproject.vocab.OWL;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.util.FileManager;
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
public class ontolo {
public static void main(String[] args) {
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
String inputFileName = "file:///F:/apache-jena-2.12.1/travel.owl";
InputStream in = FileManager.get().open( inputFileName );
if (in == null) {
throw new IllegalArgumentException("File: " + inputFileName + " not found");
}
//Property hasTime = model.createProperty( "file:///F:/apache-jena-2.12.1/shopping.owl#" );
//Property getProperty ( inputFileName, hastime) ;
model.read(in, null);
com.hp.hpl.jena.rdf.model.Property irrr = model.getProperty(OWL.ON_PROPERTIES);
com.hp.hpl.jena.rdf.model.NodeIterator iter1 = model.listObjectsOfProperty(irrr);
com.hp.hpl.jena.rdf.model.ResIterator i = model.listSubjectsWithProperty (irrr);
//com.hp.hpl.jena.rdf.model.Statement iir = model.getRequiredProperty(inputFileName, irrr);
//com.hp.hpl.jena.rdf.model.NodeIterator iter2 = model.listObjectsOfProperty(inputFileName.subClassOf);
ExtendedIterator<OntClass> iter = ((OntModel) model).listClasses();
while ( iter.hasNext()){
System.out.println(iter.next().toString());
}
// write it to standard out
model.write(System.out);
}
}