powered by simpleCommunicator - 2.0.56     © 2025 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Java [игнор отключен] [закрыт для гостей] / Не удается найти указанный файл
7 сообщений из 7, страница 1 из 1
Не удается найти указанный файл
    #39750546
nastyaa
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Я сам ели написала код) вроде без ошибок. Но почему он не может найти указанный файл

Код: java
1.
2.
3.
4.
5.
6.
7.
Exception in thread "main" java.io.FileNotFoundException: C:\Users\Adil\Desktop\Первый перевод\strings2a_kz.txt (Не удается найти указанный файл)
	at java.io.FileInputStream.open0(Native Method)
	at java.io.FileInputStream.open(FileInputStream.java:195)
	at java.io.FileInputStream.<init>(FileInputStream.java:138)
	at java.io.FileInputStream.<init>(FileInputStream.java:93)
	at java.io.FileReader.<init>(FileReader.java:58)
	at Main.main(Main.java:9)




Код: java
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.
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws IOException{
        String inputFilePath = "C:\\Users\\Nastya\\Desktop\\Первый перевод\\strings2a_kz.txt";
        String outputFilePath = "C:\\Users\\Nastya\\Desktop\\Первый перевод\\output.txt";
 
        FileReader fileReader = new FileReader(inputFilePath);
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        FileWriter fileWriter = new FileWriter(outputFilePath);
 
        String line;
        StringBuilder result = new StringBuilder();
 
        Map<String, String> dictionary = new Dictionary().getDictionary();
 
        while ((line = bufferedReader.readLine()) != null) {
            result.append(convertString(line, dictionary) + System.getProperty("line.separator")) ;
        }
 
        bufferedReader.close();
        fileReader.close();
 
        fileWriter.write(result.toString());
        fileWriter.flush();
        fileWriter.close();
    }
 
    public static String convertString(String str, Map<String, String> dictionary) {
        char[] chars = str.toCharArray();
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < chars.length; i++) {
            if (dictionary.containsKey(chars[i])) {
                stringBuilder.append(dictionary.get(chars[i]));
                continue;
            }
            stringBuilder.append(chars[i]);
        }
        return stringBuilder.toString();
    }
}
 
class Dictionary {
    private Map<String, String> dictionary;
 
    public Dictionary() {
        dictionary = new HashMap<>();
        dictionary.put("а", "a");
        dictionary.put("А", "А");
        dictionary.put("&#1241;", "&#225;");
        dictionary.put("&#1240;", "&#193;");
        dictionary.put("б", "b");
        dictionary.put("Б", "B");
        dictionary.put("д", "d");
        dictionary.put("Д", "D");
        dictionary.put("е", "e");
        dictionary.put("E", "E");
        dictionary.put("ф", "f");
        dictionary.put("Ф", "F");
        dictionary.put("г", "g");
        dictionary.put("Г", "G");
        dictionary.put("&#1171;", "&#501;");
        dictionary.put("&#1170;", "&#500;");        
        dictionary.put("х", "h");
        dictionary.put("Х", "H");
        dictionary.put("h", "&#1211;");
        dictionary.put("&#1210;", "&#1210;");
        dictionary.put("і", "i");
        dictionary.put("І", "І");
        dictionary.put("и", "&#305;");
        dictionary.put("И", "I");
        dictionary.put("й", "i");
        dictionary.put("Й", "I");
        dictionary.put("ж", "j");
        dictionary.put("Ж", "J");
        dictionary.put("к", "k");
        dictionary.put("К", "К");
        dictionary.put("л", "l");
        dictionary.put("Л", "L");
        dictionary.put("м", "m");
        dictionary.put("М", "M");
        dictionary.put("н", "n");
        dictionary.put("Н", "N");
        dictionary.put("&#1187;", "&#324;");
        dictionary.put("&#1186;", "&#323;");
        dictionary.put("о", "o");
        dictionary.put("О", "О");
        dictionary.put("&#1257;", "&#243;");
        dictionary.put("&#1256;", "&#211;");
        dictionary.put("п", "p");
        dictionary.put("П", "P");
        dictionary.put("&#1179;", "q");
        dictionary.put("&#1178;", "Q");
        dictionary.put("р", "r");
        dictionary.put("Р", "R");
        dictionary.put("с", "s");
        dictionary.put("С", "S");
        dictionary.put("ш", "sh");
        dictionary.put("Ш", "Sh");
        dictionary.put("ч", "ch");
        dictionary.put("Ч", "Сh");
        dictionary.put("т", "t");
        dictionary.put("Т", "T");
        dictionary.put("&#1199;", "&#250;");
        dictionary.put("&#1198;", "&#218;");
        dictionary.put("&#1201;", "u");
        dictionary.put("&#1200;", "U");
        dictionary.put("в", "v");
        dictionary.put("В", "V");
        dictionary.put("ы", "y");
        dictionary.put("Ы", "Y");
        dictionary.put("у", "&#253;");
        dictionary.put("У", "&#221;");
        dictionary.put("з", "z");
        dictionary.put("З", "Z");
    }
 
    public Map<String, String> getDictionary() {
        return dictionary;
    }
}
...
Рейтинг: 0 / 0
Не удается найти указанный файл
    #39750547
nastyaa
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
nastyaaЯ сам ели написала код) вроде без ошибок. Но почему он не может найти указанный файл

Код: java
1.
2.
3.
4.
5.
6.
7.
Exception in thread "main" java.io.FileNotFoundException: C:\Users\Nastya\Desktop\Первый перевод\strings2a_kz.txt (Не удается найти указанный файл)
	at java.io.FileInputStream.open0(Native Method)
	at java.io.FileInputStream.open(FileInputStream.java:195)
	at java.io.FileInputStream.<init>(FileInputStream.java:138)
	at java.io.FileInputStream.<init>(FileInputStream.java:93)
	at java.io.FileReader.<init>(FileReader.java:58)
	at Main.main(Main.java:9)




Код: java
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.
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws IOException{
        String inputFilePath = "C:\\Users\\Nastya\\Desktop\\Первый перевод\\strings2a_kz.txt";
        String outputFilePath = "C:\\Users\\Nastya\\Desktop\\Первый перевод\\output.txt";
 
        FileReader fileReader = new FileReader(inputFilePath);
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        FileWriter fileWriter = new FileWriter(outputFilePath);
 
        String line;
        StringBuilder result = new StringBuilder();
 
        Map<String, String> dictionary = new Dictionary().getDictionary();
 
        while ((line = bufferedReader.readLine()) != null) {
            result.append(convertString(line, dictionary) + System.getProperty("line.separator")) ;
        }
 
        bufferedReader.close();
        fileReader.close();
 
        fileWriter.write(result.toString());
        fileWriter.flush();
        fileWriter.close();
    }
 
    public static String convertString(String str, Map<String, String> dictionary) {
        char[] chars = str.toCharArray();
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < chars.length; i++) {
            if (dictionary.containsKey(chars[i])) {
                stringBuilder.append(dictionary.get(chars[i]));
                continue;
            }
            stringBuilder.append(chars[i]);
        }
        return stringBuilder.toString();
    }
}
 
class Dictionary {
    private Map<String, String> dictionary;
 
    public Dictionary() {
        dictionary = new HashMap<>();
        dictionary.put("а", "a");
        dictionary.put("А", "А");
        dictionary.put("&#1241;", "&#225;");
        dictionary.put("&#1240;", "&#193;");
        dictionary.put("б", "b");
        dictionary.put("Б", "B");
        dictionary.put("д", "d");
        dictionary.put("Д", "D");
        dictionary.put("е", "e");
        dictionary.put("E", "E");
        dictionary.put("ф", "f");
        dictionary.put("Ф", "F");
        dictionary.put("г", "g");
        dictionary.put("Г", "G");
        dictionary.put("&#1171;", "&#501;");
        dictionary.put("&#1170;", "&#500;");        
        dictionary.put("х", "h");
        dictionary.put("Х", "H");
        dictionary.put("h", "&#1211;");
        dictionary.put("&#1210;", "&#1210;");
        dictionary.put("і", "i");
        dictionary.put("І", "І");
        dictionary.put("и", "&#305;");
        dictionary.put("И", "I");
        dictionary.put("й", "i");
        dictionary.put("Й", "I");
        dictionary.put("ж", "j");
        dictionary.put("Ж", "J");
        dictionary.put("к", "k");
        dictionary.put("К", "К");
        dictionary.put("л", "l");
        dictionary.put("Л", "L");
        dictionary.put("м", "m");
        dictionary.put("М", "M");
        dictionary.put("н", "n");
        dictionary.put("Н", "N");
        dictionary.put("&#1187;", "&#324;");
        dictionary.put("&#1186;", "&#323;");
        dictionary.put("о", "o");
        dictionary.put("О", "О");
        dictionary.put("&#1257;", "&#243;");
        dictionary.put("&#1256;", "&#211;");
        dictionary.put("п", "p");
        dictionary.put("П", "P");
        dictionary.put("&#1179;", "q");
        dictionary.put("&#1178;", "Q");
        dictionary.put("р", "r");
        dictionary.put("Р", "R");
        dictionary.put("с", "s");
        dictionary.put("С", "S");
        dictionary.put("ш", "sh");
        dictionary.put("Ш", "Sh");
        dictionary.put("ч", "ch");
        dictionary.put("Ч", "Сh");
        dictionary.put("т", "t");
        dictionary.put("Т", "T");
        dictionary.put("&#1199;", "&#250;");
        dictionary.put("&#1198;", "&#218;");
        dictionary.put("&#1201;", "u");
        dictionary.put("&#1200;", "U");
        dictionary.put("в", "v");
        dictionary.put("В", "V");
        dictionary.put("ы", "y");
        dictionary.put("Ы", "Y");
        dictionary.put("у", "&#253;");
        dictionary.put("У", "&#221;");
        dictionary.put("з", "z");
        dictionary.put("З", "Z");
    }
 
    public Map<String, String> getDictionary() {
        return dictionary;
    }
}
...
Рейтинг: 0 / 0
Не удается найти указанный файл
    #39750612
Фотография by-pass
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
nastyaa,

Никогда не используйте в качестве каталога "Рабочий стол".
...
Рейтинг: 0 / 0
Не удается найти указанный файл
    #39750681
chpasha
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
nastyaa
Код: java
1.
Adil


никогда Штирлиц еще не был так близок к провалу
...
Рейтинг: 0 / 0
Не удается найти указанный файл
    #39750697
Фотография Dmitry.
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
nastyaa,

может файла нет по указанному пути?

Код: plaintext
C:\Users\Adil\Desktop\Первый перевод\strings2a_kz.txt
...
Рейтинг: 0 / 0
Не удается найти указанный файл
    #39750836
Фотография Dmitry.
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
nastyaaНо почему он не может найти указанный файл?

- файла нет
- кодировка исходного кода не указана во время компиляции и кириллица превращяется в Г
...
Рейтинг: 0 / 0
Не удается найти указанный файл
    #39750938
Фотография Пылинка
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
chpashanastyaa
Код: java
1.
Adil


никогда Штирлиц еще не был так близок к провалу

А также и nastyaaЯ сам ели написал а
PS не понял - они там кушали или хвойные к НГ готовили?
...
Рейтинг: 0 / 0
7 сообщений из 7, страница 1 из 1
Форумы / Java [игнор отключен] [закрыт для гостей] / Не удается найти указанный файл
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]