1
2
3
4
5
6
7
8
9
10
11
12
13 package org.astrogrid.applications.apps.tables;
14
15 import java.io.IOException;
16 import java.io.InputStream;
17 import java.io.OutputStream;
18
19 import uk.ac.starlink.table.StarTable;
20 import uk.ac.starlink.table.StarTableFactory;
21 import uk.ac.starlink.table.StarTableOutput;
22 import uk.ac.starlink.table.TableFormatException;
23
24 /***
25 * @author Paul Harrison (pah@jb.man.ac.uk) 10-Nov-2004
26 * @version $Name: HEAD $
27 * @since iteration6
28 */
29 public class TableConverter {
30
31 private final StarTableFactory factory;
32 private final StarTable inTable;
33
34 /***
35 * @param stream
36 * @param inputFomat
37 * @throws IOException
38 * @throws TableFormatException
39 *
40 */
41 public TableConverter(InputStream stream, String inputFormat) throws TableFormatException, IOException {
42 factory = new StarTableFactory();
43 inTable = factory.makeStarTable(new StreamDataSource(stream), inputFormat);
44
45
46 }
47
48 public void write(String outputFormat) throws TableFormatException, IOException
49 {
50
51 new StarTableOutput().writeStarTable(inTable, outputFormat, outputFormat);
52 }
53
54
55 }