Search in sources :

Example 91 with LineNumberReader

use of java.io.LineNumberReader in project webanno by webanno.

the class WebannoTsv3XReader method getNext.

@Override
public void getNext(JCas aJCas) throws IOException, CollectionException {
    Resource res = nextFile();
    initCas(aJCas, res);
    try (LineNumberReader br = new LineNumberReader(new InputStreamReader(res.getInputStream(), encoding))) {
        new Tsv3XDeserializer().read(br, aJCas);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) Tsv3XDeserializer(de.tudarmstadt.ukp.clarin.webanno.tsv.internal.tsv3x.Tsv3XDeserializer) LineNumberReader(java.io.LineNumberReader)

Example 92 with LineNumberReader

use of java.io.LineNumberReader in project zotero-libreoffice-integration by zotero.

the class RegistrationHandler method findServicesImplementationClasses.

/**
 * @return all the UNO implementation classes.
 */
@SuppressWarnings("unchecked")
private static Class[] findServicesImplementationClasses() {
    ArrayList<Class> classes = new ArrayList<Class>();
    InputStream in = RegistrationHandler.class.getResourceAsStream("RegistrationHandler.classes");
    LineNumberReader reader = new LineNumberReader(new InputStreamReader(in));
    try {
        String line = reader.readLine();
        while (line != null) {
            if (!line.equals("")) {
                line = line.trim();
                try {
                    Class clazz = Class.forName(line);
                    Class[] writeTypes = new Class[] { XRegistryKey.class };
                    Class[] getTypes = new Class[] { String.class };
                    Method writeRegMethod = clazz.getMethod("__writeRegistryServiceInfo", writeTypes);
                    Method getFactoryMethod = clazz.getMethod("__getComponentFactory", getTypes);
                    if (writeRegMethod != null && getFactoryMethod != null) {
                        classes.add(clazz);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            line = reader.readLine();
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            reader.close();
            in.close();
        } catch (Exception e) {
        }
        ;
    }
    return classes.toArray(new Class[classes.size()]);
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) XRegistryKey(com.sun.star.registry.XRegistryKey) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) IOException(java.io.IOException) IOException(java.io.IOException) LineNumberReader(java.io.LineNumberReader)

Example 93 with LineNumberReader

use of java.io.LineNumberReader in project tesb-rt-se by Talend.

the class RunTrace method isNextRow.

public boolean isNextRow() {
    if (!openSocket) {
        return false;
    }
    InputStream in;
    try {
        askForStatus();
        in = s.getInputStream();
        LineNumberReader reader = new LineNumberReader(new InputStreamReader(in));
        // $NON-NLS-1$
        return "NEXT_ROW".equals(reader.readLine());
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) IOException(java.io.IOException) LineNumberReader(java.io.LineNumberReader)

Example 94 with LineNumberReader

use of java.io.LineNumberReader in project tesb-rt-se by Talend.

the class RunTrace method waitForUserAction.

public void waitForUserAction() throws InterruptedException {
    if (!openSocket) {
        return;
    }
    InputStream in;
    try {
        boolean action = false;
        // $NON-NLS-1$
        pred.println("UI_STATUS");
        do {
            in = s.getInputStream();
            LineNumberReader reader = new LineNumberReader(new InputStreamReader(in));
            String line = reader.readLine();
            if ("STATUS_WAITING".equals(line)) {
                pred.println("UI_STATUS");
                Thread.sleep(100);
            } else {
                action = true;
            }
        } while (!action);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) IOException(java.io.IOException) LineNumberReader(java.io.LineNumberReader)

Example 95 with LineNumberReader

use of java.io.LineNumberReader in project tesb-rt-se by Talend.

the class RunTrace method isPause.

public boolean isPause() {
    if (!openSocket) {
        return false;
    }
    InputStream in;
    try {
        askForStatus();
        in = s.getInputStream();
        LineNumberReader reader = new LineNumberReader(new InputStreamReader(in));
        // $NON-NLS-1$
        return "PAUSE".equals(reader.readLine());
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) IOException(java.io.IOException) LineNumberReader(java.io.LineNumberReader)

Aggregations

LineNumberReader (java.io.LineNumberReader)401 IOException (java.io.IOException)203 InputStreamReader (java.io.InputStreamReader)167 FileReader (java.io.FileReader)102 File (java.io.File)79 InputStream (java.io.InputStream)64 StringReader (java.io.StringReader)64 ArrayList (java.util.ArrayList)54 FileInputStream (java.io.FileInputStream)33 BufferedReader (java.io.BufferedReader)27 PrintWriter (java.io.PrintWriter)25 HashMap (java.util.HashMap)22 FileNotFoundException (java.io.FileNotFoundException)20 BufferedWriter (java.io.BufferedWriter)16 FileWriter (java.io.FileWriter)16 Pattern (java.util.regex.Pattern)16 Test (org.junit.jupiter.api.Test)16 ByteArrayInputStream (java.io.ByteArrayInputStream)15 ByteArrayOutputStream (java.io.ByteArrayOutputStream)15 Reader (java.io.Reader)14