![]() |
|
Модераторы: LSD, AntonSaburov |
![]()
|
|
| LAKERS |
|
|||
![]() Бывалый ![]() Профиль Группа: Участник Сообщений: 156 Регистрация: 10.2.2006 Где: Москва Репутация: нет Всего: нет |
выдает ошибку...
c:\test>javac GridBagLayoutWindow.java GridBagLayoutWindow.java:75: Exception java.io.FileNotFoundException must be cau ght, or it must be declared in the throws clause of this method. input = new FileInputStream (file); ^ 1 error соответсвенно я эти две строки
они у меня находятся в разных {} ??? |
|||
|
||||
| LAKERS |
|
|||
![]() Бывалый ![]() Профиль Группа: Участник Сообщений: 156 Регистрация: 10.2.2006 Где: Москва Репутация: нет Всего: нет |
не могу выдернуть файл из FileDialog чтобы отправить его через нажатие PUT
[code=java] import java.awt.*; import java.awt.event.*; import java.net.*; import java.io.*; import org.apache.commons.net.ftp.*; public class GridBagLayoutWindow extends Frame implements ActionListener { private TextField tF3 = null; private TextArea textArea = null; private DataInputStream dis = null; private InputStream input; private OutputStream output; private Button b = new Button("Open"); File file; protected void makebutton(String name, GridBagLayout gridbag, GridBagConstraints c) { Button button = new Button(name); gridbag.setConstraints(button, c); add(button); button.addActionListener(this); } public GridBagLayoutWindow(String title) { super(title); // handle frame closing events addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } } ); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setFont(new Font("Helvetica", Font.PLAIN, 14)); setLayout(gridbag); c.fill = GridBagConstraints.NONE; c.insets = new Insets(5,5,5,5); c.weightx = 1.0; c.anchor = GridBagConstraints.CENTER; TextField tF1 = new TextField("Enter IP", 25); add(tF1); c.gridwidth = GridBagConstraints.REMAINDER; makebutton("OK", gridbag, c); TextField tF2 = new TextField("STATUS", 25); add(tF2); c.gridwidth = GridBagConstraints.REMAINDER; makebutton("GET File", gridbag, c); c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; makebutton("PUT File", gridbag, c); tF3 = new TextField(20); add(tF3); add(b); b.addActionListener(this); } //Pressing the Open button triggers an ActionEvent, sent to the application with an invocation of the actionPerformed method. public void actionPerformed(ActionEvent evt) { FTPClient ftp = new FTPClient(); Object sc = evt.getSource(); String cmd = evt.getActionCommand(); if (sc == b) { FileDialog dialog = new FileDialog(this, "Open a file", FileDialog.LOAD); dialog.show(); tF3.setText(dialog.getFile()); File file = new File (dialog.getDirectory(), dialog.getFile()); System.out.println(file.getAbsolutePath()); } if (cmd == "PUT File") { try { input = new FileInputStream (file); ftp.connect("192.168.123.254"); ftp.login("Administrator", "11111"); ftp.setFileType(FTP.ASCII_FILE_TYPE); ftp.enterLocalPassiveMode(); System.out.println("Connected"); ftp.makeDirectory("\\test"); System.out.println("MakeDirectory"); ftp.appendFile("\\test\\1.txt", input); System.out.println("Input OK"); System.out.println("Remote syst |
|||
|
||||
| batigoal |
|
|||
![]() Нелетучий Мыш ![]() ![]() ![]() ![]() Профиль Группа: Участник Клуба Сообщений: 6423 Регистрация: 28.12.2004 Где: Санктъ-Петербургъ Репутация: 24 Всего: 151 |
FileNotFoundException может быть выброшено при создании FileInputStream(). Добавлено @ 15:48 В смысле - не можешь? -------------------- "Чтобы правильно задать вопрос, нужно знать большую часть ответа" (Р. Шекли) ЖоржЖЖ |
|||
|
||||
| LAKERS |
|
|||
![]() Бывалый ![]() Профиль Группа: Участник Сообщений: 156 Регистрация: 10.2.2006 Где: Москва Репутация: нет Всего: нет |
все, решил проблему...
|
|||
|
||||
| LAKERS |
|
|||
![]() Бывалый ![]() Профиль Группа: Участник Сообщений: 156 Регистрация: 10.2.2006 Где: Москва Репутация: нет Всего: нет |
еще, на КПК почему-то текстовые поля у меня минимальной формы, хотя я устанавливаю и тестирую на ПК все идет нормально, размеры 25...почему так может быть?
|
|||
|
||||
| LSD |
|
|||
![]() Leprechaun Software Developer ![]() ![]() ![]() ![]() Профиль Группа: Модератор Сообщений: 15719 Регистрация: 24.3.2004 Где: Dublin Репутация: 210 Всего: 538 |
Модератор: Пожалуйста, один топик - один вопрос.
Создай новую тему, опиши поподробней проблему, что за компоненты как располагаешь и т.д. -------------------- Disclaimer: this post contains explicit depictions of personal opinion. So, if it sounds sarcastic, don't take it seriously. If it sounds dangerous, do not try this at home or at all. And if it offends you, just don't read it. |
|||
|
||||
![]()
|
| Правила форума "Java" | |
|
|
Если Вам помогли, и атмосфера форума Вам понравилась, то заходите к нам чаще! С уважением, LSD, AntonSaburov, powerOn, tux, javastic. |
| 0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей) | |
| 0 Пользователей: | |
| « Предыдущая тема | Java: Общие вопросы | Следующая тема » |
|
|
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности Powered by Invision Power Board(R) 1.3 © 2003 IPS, Inc. |