Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 6935205398208;Краска;52,15
- 6920702797104;Сметана;4,25
- 353891040181013;Сыр;12,86
- U6LDU13B30001710;Молоко;7,85
- // Get the File path from the Uri
- String path = FileUtils.getPath(this, uri);
- // Alternatively, use FileUtils.getFile(Context, Uri)
- if (path != null && FileUtils.isLocal(path)) {
- File file = new File(path);
- Log.i(TAG, "onActivityResult: "+file.getName());
- //File sdFile = new File(file, file.getName());
- try {
- // открываем поток для чтения
- BufferedReader br = new BufferedReader(new FileReader(file));
- String str = "";
- int i=0;
- // читаем содержимое
- while ((str = br.readLine()) != null) {
- createRecordProductInRealm(str);
- i=i+1;
- Log.i(TAG, "onActivityResult: *************** "+str);
- String tmp = str;
- tmp = new String(str.getBytes("windows-1251"), "windows-1251"); Log.i(TAG, "onActivityResult: "+tmp);
- tmp = new String(str.getBytes("windows-1251")); Log.i(TAG, "onActivityResult: "+tmp);
- tmp = new String(str.getBytes(), "KOI8-R"); Log.i(TAG, "onActivityResult: "+tmp);
- tmp = new String(str.getBytes(), "UTF-8"); Log.i(TAG, "onActivityResult: "+tmp);
- tmp = new String(str.getBytes(), "UTF-16"); Log.i(TAG, "onActivityResult: "+tmp);
- tmp = new String(str.getBytes(), "Cp1251"); Log.i(TAG, "onActivityResult: "+tmp);
- tmp = new String(str.getBytes(), "Cp866"); Log.i(TAG, "onActivityResult: "+tmp);
- Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
- }
- //Toast.makeText(context, "Загружено "+i+" товаров", Toast.LENGTH_SHORT).show();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement