Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void imprimir(String frase) {
- //Gera o arquivo de desconto
- try {
- File arquivo = new File("teste.txt");
- if (arquivo.exists()) {
- //se existir
- FileWriter arquivoTxt = new FileWriter(arquivo, true);
- PrintWriter linhasTxt = new PrintWriter(arquivoTxt);
- //ACREDITO QUE SO PODE TER 42 CARACTERES
- linhasTxt.println("==========================================");
- linhasTxt.println(" Thiosti Restaurante ");
- linhasTxt.println("===========================================");
- linhasTxt.println("********** NAO E DOCUMENTO FISCAL *********");
- linhasTxt.println("===========================================");
- linhasTxt.println("============= CUPOM DE DESCONTO ============");
- linhasTxt.println("===========================================");
- linhasTxt.println(frase);
- linhasTxt.println("===========================================");
- linhasTxt.println(" Agradecemos a preferencia! ");
- linhasTxt.println("Delivery - 3095-3838");
- //emiteComanda();
- } else {
- //se não existir
- arquivo.createNewFile();
- //criaTxt();
- }
- } catch (IOException error) {
- System.out.println("nao encontrei arquivo");
- }
- try {
- java.io.InputStream is = new FileInputStream("teste.txt");
- Scanner sc = new Scanner(is);
- FileOutputStream fs = new FileOutputStream("Bematech_COM3:");
- PrintStream ps = new PrintStream(fs);
- while (sc.hasNextLine()) {
- String linhas = sc.nextLine();
- ps.println(linhas);
- }
- fs.close();
- } catch (IOException ex) {
- ex.printStackTrace();
- JOptionPane.showMessageDialog(null, "Erro encontrado ao imprimir comanda." + ex.toString());
- }
- }
Add Comment
Please, Sign In to add comment