Advertisement
Guest User

Untitled

a guest
May 26th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4.     public class filunlukija{
  5.            private static Scanner lukija = new Scanner(System.in);
  6.     public static void main (String args[]) {
  7.         String[] tekstiTaulukko = new String[1000000];
  8.  
  9.       int i = 0;
  10.       int rivimaara = 0;
  11.       String rivi = lukija.nextLine();
  12.       String b = lukija.nextLine();
  13.       try{
  14.  
  15.     FileInputStream fstream = new FileInputStream("asd.txt");  // avaa tiedosto joka on tossa
  16.  
  17.     DataInputStream in = new DataInputStream(fstream);
  18.         BufferedReader br = new BufferedReader(new InputStreamReader(in));
  19.     String strLine;
  20.  
  21.     while ((strLine = br.readLine()) != null)   {  //Lue file rivi rivilt�
  22.  
  23.      tekstiTaulukko[i] = new String(strLine); // lisätään taulukon vikaan riviin yks lisää
  24.              rivimaara = i;
  25.         ++i;
  26.  
  27.     }
  28.  
  29.  
  30.    
  31.       in.close();  //sulje input streami
  32.    
  33.      tekstiTaulukko[rivimaara]=new String(rivi);
  34.         FileOutputStream fos = new FileoutputStream("asd.txt");
  35.         OutputStreamWriter out = new OutputStreamWriter(fos, "UTF-8");
  36.         BufferedReader input =  new BufferedReader(new FileReader("asd.txt"));
  37.          System.out.println("Anna lisättävä rivi");
  38.          
  39.    
  40.  
  41.  
  42.  
  43.     }catch (Exception e){
  44.       System.err.println("Error: " + e.getMessage());
  45.     }
  46.   }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement