С Новым годом! Форум программистов, компьютерный форум, киберфорум
Java SE (J2SE)
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 5.00/7: Рейтинг темы: голосов - 7, средняя оценка - 5.00
0 / 0 / 0
Регистрация: 08.10.2012
Сообщений: 50

Поток и запись в файл

14.06.2014, 06:45. Показов 1400. Ответов 5
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
Здравствуйте, помоги пожалуйста с проблемой.
Пишу поток, который считывает метаданные, в данном случае информацию о процессоре. Так вот, надо чтобы поток записывал результат в timer.txt файл до тех пор, пока он не привысит 5 мб. После того как файл стал 5мб+ программа меняет имя файла на timer_"дата".txt, после чего опять создает новый файл названием timer.txt. И так по кругу. Остановку делать не надо, я её сделаю когда переделывать с интерфейсом буду.
Проблема в том что я застрял на этапе записи в файл, не знаю как правильно сделать.
Вот код и библиотека, которую я использую для вывода инфы о процессоре.
Code
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
71
72
73
74
75
76
77
78
79
80
81
82
83
package daemonthread;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.hyperic.sigar.CpuInfo;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
 
/**
 * The Class DaemonThread.
 * 
 * Created on: 05.06.2014
 * 
 * @author: Sinderlok
 */
class DaemonThread implements Runnable{
    private String d;
    private String f;
    private String st1;
    
    private void processSomething() throws SigarException, IOException {
        try {
            CpuInfo cpu = new Sigar().getCpuInfoList()[0];
            System.out.println("CPU Info");
            System.out.println("Vendor: " + cpu.getVendor());
            System.out.println("Model: " + cpu.getModel());
            System.out.println("Cores: " + cpu.getCoresPerSocket());
            System.out.println("Frequency: " + cpu.getMhz());
            System.out.println("Cache: " + cpu.getCacheSize());
            Thread.sleep(1000);
            
         // Запись в файл
           String d = f.substring(0, f.length()-9);
            File flt = new File(d);
            flt.mkdirs();
            File mypath = new File(f);
            mypath.createNewFile();
            String str1 = new SimpleDateFormat("dd,MM.yyyy_h.mm.ss").format(new Date()); 
            String str2 = d + "timer_" + str1 + ".txt";
       // создание нового файла после заполнения старого
            if (mypath.length() >= 5120 * 1024) { 
                File mypath1 = new File(str1);
                mypath.renameTo(mypath1);
                mypath.createNewFile();
            }
            FileWriter wrt = new FileWriter(mypath, true);
            File file = new File(st1);
 
           
            
            
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    
    @Override
    public void run() {
        while(true){
            try {
                processSomething();
            } catch (SigarException ex) {
                Logger.getLogger(DaemonThread.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(DaemonThread.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
    
   public static void main(String[] args) throws InterruptedException  {
       Thread dt = new Thread(new DaemonThread(), "dt");
 
        dt.setDaemon(true);
        dt.start();
 
      Thread.sleep(3000);
      System.out.println("Finishing program");
   }
}
Вложения
Тип файла: rar hyperic-sigar-1.6.4.rar (2.87 Мб, 6 просмотров)
0
IT_Exp
Эксперт
34794 / 4073 / 2104
Регистрация: 17.06.2006
Сообщений: 32,602
Блог
14.06.2014, 06:45
Ответы с готовыми решениями:

Запись байтов в файл через поток
Записываю байты в файл через поток: static BYTE SignBuffer; ofstream os("Test.txt"); os.write(SignBuffer, 64); os.close(); ...

При запуске сервиса поток повисает, и запись в файл не происходит
Всем привет! Такая проблема, при запуске сервиса поток повисает, и запись в файл не происходит. Но при остановке сервиса всё начинает...

Нужно создать базу данных (создать пустой бинарный файл). Через поток. Поток бинарного файла описать в виде локальной переменной внутри функции.
Совсем не понял эту тему. Нужно создать базу данных (создать пустой бинарный файл). Через поток. Поток бинарного файла описать в виде...

5
0 / 0 / 0
Регистрация: 08.10.2012
Сообщений: 50
14.06.2014, 10:49  [ТС]
Почти доделал, но не знаю как записать str в файл.
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
String d = f.substring(0, f.length()-9);
            File flt = new File(d);
            flt.mkdirs();
            File mypath = new File(f);
            mypath.createNewFile();
            String str1 = new SimpleDateFormat("dd,MM.yyyy_h.mm.ss").format(new Date()); 
            String str2 = d + "timer_" + str1 + ".txt";
            if (mypath.length() >= 5120 * 1024) { 
                File mypath1 = new File(str1);
                mypath.renameTo(mypath1);
                mypath.createNewFile();
            }
            FileWriter wrt = new FileWriter(mypath, true);
            File file = new File(st1);
            String str = "";
            
           str= new SimpleDateFormat("dd.MM.yyyy  hh:mm:ss").format(new Date())+ "\r\n"+"CPU Info"+"\r\n"+"Vendor: " + cpu.getVendor()+"\r\n"
                                +"Model: " + cpu.getModel()+"\r\n"+ "Cores: " + cpu.getCoresPerSocket()+"\r\n"+"Frequency: " + cpu.getMhz()+"\r\n"
                                +"Cache: " + cpu.getCacheSize()+"\r\n";
            
            wrt.write(str);
            wrt.close();
            Thread.sleep(1000);
0
Эксперт Java
 Аватар для KEKCoGEN
2399 / 2224 / 565
Регистрация: 28.12.2010
Сообщений: 8,672
14.06.2014, 15:42
используйте логгер. Например log4j. Он предоставляет эту функциональность.
0
0 / 0 / 0
Регистрация: 08.10.2012
Сообщений: 50
14.06.2014, 16:41  [ТС]
Никогда раньше пользовался ими. Даже не знаю как, язык знаю на зачатачном уровне. Все что вы видите это мой предел.
0
Эксперт Java
 Аватар для KEKCoGEN
2399 / 2224 / 565
Регистрация: 28.12.2010
Сообщений: 8,672
14.06.2014, 17:00
Тогда вам следует тщательнее изучить язык чтобы реализовать то что вам нужно.
0
0 / 0 / 0
Регистрация: 08.10.2012
Сообщений: 50
15.06.2014, 11:59  [ТС]
Изменил код, сделал со Swing. Кнопка start и stop. Теперь хочу с помощью JFileChooser выбрать файл для записи туда результата. Но не знаю как, помогите пожалуйста.
Код с java.Swing

Code
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import java.awt.FlowLayout;  
import java.awt.event.ActionEvent;  
import java.awt.event.ActionListener;  
  
import javax.swing.JButton;  
import javax.swing.JFrame;  
/**
 *
 * @author Sinderlok
 */
public class DaemonThreadRunner extends JFrame {
private JButton startBtn;  
      
    private JButton stopBtn;  
       
      
    private DaemonThread myThread;  
      
    public DaemonThreadRunner() {  
     
        startBtn = new JButton("Start");  
        stopBtn = new JButton("Stop");    
        stopBtn.setEnabled(false);    
        this.getContentPane().setLayout(new FlowLayout());  
        this.getContentPane().add(startBtn);  
        this.getContentPane().add(stopBtn);    
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
        this.pack();  
        this.setVisible(true);  
          
        startBtn.addActionListener(new ActionListener() {  
            public void actionPerformed(ActionEvent ae) {  
                myThread = new DaemonThread();  
                Thread t = new Thread(myThread);  
                t.setDaemon(true);  
                myThread.runnable = true;  
                t.start();  
                stopBtn.setEnabled(true);  
                startBtn.setEnabled(false);  
            }  
        });  
          
        stopBtn.addActionListener(new ActionListener() {  
            public void actionPerformed(ActionEvent ae) {  
                        myThread.runnable = false;
                        stopBtn.setEnabled(false); 
                        startBtn.setEnabled(true);  
            }  
        });  
          
          
    }  
  
 
 
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {
 
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
 
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
 
        pack();
    }// </editor-fold>                        
 
    /**
     * @param args the command line arguments
     */
     public static void main(String[] args) {  
        // TODO Auto-generated method stub  
        DaemonThreadRunner obj = new DaemonThreadRunner();  
          
    }  
  
}
Код с демоном и не законченым filewriter.
Code
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package thread;
 
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.hyperic.sigar.CpuInfo;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
 
/**
 *
 * @author Sinderlok
 */
public class DaemonThread implements Runnable {  
      
    protected volatile boolean runnable = false;  
    private PrintStream core;
    private Object f;
    private String st1;
    private String d;
  
    @Override  
    public  void run() {  
        
         
        synchronized(this) {  
            try {  
                while(runnable) {  
                  
                    CpuInfo cpu = new Sigar().getCpuInfoList()[0];
            System.out.println("CPU Info");
            System.out.println("Vendor: " + cpu.getVendor());
            System.out.println("Model: " + cpu.getModel());
            System.out.println("Cores: " + cpu.getCoresPerSocket());
            System.out.println("Frequency: " + cpu.getMhz());
            System.out.println("Cache: " + cpu.getCacheSize());  
            
            String fd = d.substring(0, d.length() - 9);
                    File flt = new File(fd);
 
           
                    File mypath = new File(d);
                    flt.mkdirs();
                    mypath.createNewFile();
                    String str2 = new SimpleDateFormat("dd.MM.yyyy_h.mm.ss").format(new Date());
                    String str1 = fd + "timer_" + str2 + ".txt";
                    if (mypath.length() >= 5120 * 1024) {
                        File mypath1 = new File(str1);
                        mypath.renameTo(mypath1);
                        mypath.createNewFile();
                    }
                    FileWriter fw = new FileWriter(mypath, true);
                    File file = new File(st1);
                    String str = "";
                   
                    str= new SimpleDateFormat("dd.MM.yyyy  hh:mm:ss").format(new Date())+ "\r\n"+"CPU Info"+"\r\n"+"Vendor: " + cpu.getVendor()+"\r\n"
                            +"Model: " + cpu.getModel()+"\r\n"+ "Cores: " + cpu.getCoresPerSocket()+"\r\n"+"Frequency: " + cpu.getMhz()+"\r\n"
                            +"Cache: " + cpu.getCacheSize()+"\r\n";
                   
                    fw.write(str);
                    fw.close();
            
            
                    Thread.sleep(3000);  
                    if(runnable == false) {  
                        System.out.println("Going to wait()");  
                        this.wait();  
                    }  
                }  
                  
            } catch(InterruptedException ie) {  
                ie.printStackTrace();  
            } catch (SigarException ex) {
                Logger.getLogger(DaemonThread.class.getName()).log(Level.SEVERE, null, ex);
            } catch (FileNotFoundException ex) {
                Logger.getLogger(DaemonThread.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(DaemonThread.class.getName()).log(Level.SEVERE, null, ex);
            }  
        }  
  
    }  
  
}
Добавлено через 4 часа 27 минут
Так, опять переделал код.))
Сделал с JFileChooser. Но все равно не могу сделать чтобы демон записывал результат в текстовый файл.
Code
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
package thread;
 
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import org.hyperic.sigar.CpuInfo;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
import javax.swing.Timer;
 
/**
 *
 * @author Sinderlok
 */
public class DaemonThreadRunner extends JFrame {
 
    protected volatile boolean runnable = false;
    private Object f;
    private String d;
    javax.swing.Timer t;
    private int text;
 
    public DaemonThreadRunner() {
        initComponents();
    }
 
    public void run(boolean runnable) {
 
        if (runnable == true) {
 
            t = new Timer(100, new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    try {
 
                        CpuInfo cpu = new Sigar().getCpuInfoList()[0];
                        System.out.println("CPU Info");
                        System.out.println("Vendor: " + cpu.getVendor());
                        System.out.println("Model: " + cpu.getModel());
                        System.out.println("Cores: " + cpu.getCoresPerSocket());
                        System.out.println("Frequency: " + cpu.getMhz());
                        System.out.println("Cache: " + cpu.getCacheSize());
 
                        String fd = d.substring(0, d.length() - 9);
                        File flt = new File(fd);
 
                        File mypath = new File(d);
                        flt.mkdirs();
                        mypath.createNewFile();
                        String str2 = new SimpleDateFormat("dd.MM.yyyy_h.mm.ss").format(new Date());
                        String str1 = fd + "timer_" + str2 + ".txt";
                        if (mypath.length() >= 5120 * 1024) {
                            File mypath1 = new File(str1);
                            mypath.renameTo(mypath1);
                            mypath.createNewFile();
                        }
                        FileWriter fw = new FileWriter(mypath, true);
                        String str = "";
 
                        str = new SimpleDateFormat("dd.MM.yyyy  hh:mm:ss").format(new Date()) + "\r\n" + "CPU Info" + "\r\n" + "Vendor: " + cpu.getVendor() + "\r\n"
                                + "Model: " + cpu.getModel() + "\r\n" + "Cores: " + cpu.getCoresPerSocket() + "\r\n" + "Frequency: " + cpu.getMhz() + "\r\n"
                                + "Cache: " + cpu.getCacheSize() + "\r\n";
 
                        fw.write(str);
 
                        t.restart();
                    } catch (SigarException ex) {
                        Logger.getLogger(DaemonThreadRunner.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (IOException ex) {
                        Logger.getLogger(DaemonThreadRunner.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            });
            t.start();
 
        } else {
            System.out.println("Going to wait()");
            t.stop();
 
        }
 
    }
 
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {
 
        jButton4 = new javax.swing.JButton();
        jTextField2 = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
 
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });
 
        jButton4.setText("Обзор");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
 
        jTextField2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField2ActionPerformed(evt);
            }
        });
 
        jButton1.setText("Start");
        jButton1.setActionCommand("Start");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
 
        jButton2.setText("Stop");
        jButton2.setActionCommand("Stop");
        jButton2.setBorderPainted(false);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
 
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton2))
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 256, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton4)
                .addContainerGap(106, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton4))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(123, Short.MAX_VALUE))
        );
 
        pack();
    }// </editor-fold>                        
 
    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
        if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
            File file = fileChooser.getSelectedFile();
            if (file.isDirectory()) {
                jTextField2.setText(file.getPath() + "\\timer.txt");
            }
        }
    }                                        
 
    private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {                                            
        // TODO add your handling code here:
    }                                           
 
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        text = Integer.parseInt(jTextField2.getText()) * 1000;
        d = jTextField2.getText();
        
        this.run(runnable = true);
    }                                        
 
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        this.run(runnable = false);
    }                                        
 
    private void formWindowOpened(java.awt.event.WindowEvent evt) {                                  
 
 
    }                                 
 
    public static void main(String args[]) {
  
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(DaemonThreadRunner.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(DaemonThreadRunner.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(DaemonThreadRunner.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(DaemonThreadRunner.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
 
        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new DaemonThreadRunner().setVisible(true);
            }
        });
    }
 
    // Variables declaration - do not modify                     
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton4;
    private javax.swing.JTextField jTextField2;
    // End of variables declaration                   
}
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
BasicMan
Эксперт
29316 / 5623 / 2384
Регистрация: 17.02.2009
Сообщений: 30,364
Блог
15.06.2014, 11:59
Помогаю со студенческими работами здесь

Запись в поток
Вот такое дело, написал код: #include&lt;clocale&gt; #include&lt;stdio.h&gt; #include &lt;unistd.h&gt; #include &lt;string&gt; #include &lt;unistd.h&gt; ...

Поток: открыть любой файл, определить его размер и занести в новый файл
очень нужно решить две задачи 1.Создать поток открывающий любой файл,определить его размер и занести в новый файл. 2.Создать...

Запись строк в поток
if((f=fopen(&quot;d://Scanners.bin&quot;,&quot;a&quot;))=0) cout&lt;&lt;&quot;Fail&quot;; ..... //формирование строки тип char if (fputs(rec.model,f)!=EOF)...

Запись звука в поток
Добрый день. Опять я. Задача: Записать звук с микрофона в поток, т.е. в QDataStream. проблема: как сказать QAudioInput'у или...

Запись в поток из кода
Имеется некая функция для чтения данных из потока public void Input(Stream s, ...) { var a = new StreamReader(s); ... } ...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
6
Ответ Создать тему
Новые блоги и статьи
изучаю kubernetes
lagorue 13.01.2026
А пригодятся-ли мне знания kubernetes в России?
сукцессия микоризы: основная теория в виде двух уравнений.
anaschu 11.01.2026
https:/ / rutube. ru/ video/ 7a537f578d808e67a3c6fd818a44a5c4/
WordPad для Windows 11
Jel 10.01.2026
WordPad для Windows 11 — это приложение, которое восстанавливает классический текстовый редактор WordPad в операционной системе Windows 11. После того как Microsoft исключила WordPad из. . .
Classic Notepad for Windows 11
Jel 10.01.2026
Old Classic Notepad for Windows 11 Приложение для Windows 11, позволяющее пользователям вернуть классическую версию текстового редактора «Блокнот» из Windows 10. Программа предоставляет более. . .
Почему дизайн решает?
Neotwalker 09.01.2026
В современном мире, где конкуренция за внимание потребителя достигла пика, дизайн становится мощным инструментом для успеха бренда. Это не просто красивый внешний вид продукта или сайта — это. . .
Модель микоризы: классовый агентный подход 3
anaschu 06.01.2026
aa0a7f55b50dd51c5ec569d2d10c54f6/ O1rJuneU_ls https:/ / vkvideo. ru/ video-115721503_456239114
Owen Logic: О недопустимости использования связки «аналоговый ПИД» + RegKZR
ФедосеевПавел 06.01.2026
Owen Logic: О недопустимости использования связки «аналоговый ПИД» + RegKZR ВВЕДЕНИЕ Введу сокращения: аналоговый ПИД — ПИД регулятор с управляющим выходом в виде числа в диапазоне от 0% до. . .
Модель микоризы: классовый агентный подход 2
anaschu 06.01.2026
репозиторий https:/ / github. com/ shumilovas/ fungi ветка по-частям. коммит Create переделка под биомассу. txt вход sc, но sm считается внутри мицелия. кстати, обьем тоже должен там считаться. . . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru