wu
2025-03-19 1d0a4978574e2b67b4ed04783465710978dbdaba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package ng.db;
import builder.MachineManager;
import druidConnect.getMeterParatermeter;
 
import javax.sql.rowset.Predicate;
import java.io.*;
import java.net.URL;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Objects;
 
public class sendOptFile {
    static MachineManager mmgr;
 
    //uploadImage("D:/11.jpg", "file://10.153.19.25//¹²Ïí//11.jpg");  //µ÷Óò¢²âÊÔ
 
    /**
     * Í¨¹ýÍøÂçurlÈ¡Îļþ£¬²¢±£´æ
     *  @param path
     *            Îļþ±£´æÂ·¾¶
     * @param url
     */
    public static void sendOpt(String path, String url) {
        try {
            //ɾ³ýÎļþ¼ÐÏÂÎļþ
            LinkedList<LinkedHashMap> orderOpt=getMeterParatermeter.getOrderOpt();
            File directory = new File("\\\\192.168.10.25\\optfile");
            for (File file: Objects.requireNonNull(directory.listFiles())) {
                if (!file.isDirectory()) {
                    file.delete();
                }
            }
            path+= orderOpt.get(0).get("optfileName");
            url+=orderOpt.get(0).get("optfileName");
           URL pathUrl = new URL(url);
            DataInputStream dataInputStream = new DataInputStream(pathUrl.openStream());
            File file = new File(path);
 
            try (BufferedReader br = new BufferedReader(new InputStreamReader(dataInputStream,"utf-8"))) {
                String line;
                FileWriter writer = new FileWriter(file);
                while ((line = br.readLine()) != null) {
 
                    if(line.equals("Pieces=100")){
                        line="Pieces="+orderOpt.get(0).get("largeglass_no");
                    }
                    writer.write(line+"\n");
                }
                writer.flush();
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
 
            dataInputStream.close();// ¹Ø±ÕÊäÈëÁ÷
 
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
 
    public static void main(String[] args) throws Exception {
        sendOpt("\\\\192.168.10.25\\optfile/", "file:///d/optfile/");
    }
 
}