Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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 auto_database;
- import java.net.*;
- import java.io.*;
- public class Auto_database {
- public static void main(String[] args) {
- URL carUrl; // car's URL
- try {
- // get URL
- carUrl = new URL("http://www.auto24.ee/used/2435664");
- URLConnection carConn = carUrl.openConnection();
- // open the stream
- BufferedReader br = new BufferedReader(new InputStreamReader(carConn.getInputStream()));
- String inputLine;
- String fileName = "sourceFile.txt";
- File file = new File(fileName);
- if (!file.exists())
- file.createNewFile();
- FileWriter fw = new FileWriter(file.getAbsoluteFile());
- BufferedWriter bw = new BufferedWriter(fw);
- while ((inputLine = br.readLine()) != null)
- {
- bw.write(inputLine);
- bw.write("\n");
- }
- bw.close();
- br.close();
- System.out.println("Bravisimo");
- }
- catch (MalformedURLException e) {
- e.printStackTrace();
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement