Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. 6935205398208;Краска;52,15
  2. 6920702797104;Сметана;4,25
  3. 353891040181013;Сыр;12,86
  4. U6LDU13B30001710;Молоко;7,85
  5.  
  6. // Get the File path from the Uri
  7. String path = FileUtils.getPath(this, uri);
  8.  
  9. // Alternatively, use FileUtils.getFile(Context, Uri)
  10. if (path != null && FileUtils.isLocal(path)) {
  11. File file = new File(path);
  12. Log.i(TAG, "onActivityResult: "+file.getName());
  13.  
  14. //File sdFile = new File(file, file.getName());
  15. try {
  16. // открываем поток для чтения
  17. BufferedReader br = new BufferedReader(new FileReader(file));
  18. String str = "";
  19. int i=0;
  20. // читаем содержимое
  21. while ((str = br.readLine()) != null) {
  22. createRecordProductInRealm(str);
  23. i=i+1;
  24.  
  25. Log.i(TAG, "onActivityResult: *************** "+str);
  26. String tmp = str;
  27. tmp = new String(str.getBytes("windows-1251"), "windows-1251"); Log.i(TAG, "onActivityResult: "+tmp);
  28. tmp = new String(str.getBytes("windows-1251")); Log.i(TAG, "onActivityResult: "+tmp);
  29. tmp = new String(str.getBytes(), "KOI8-R"); Log.i(TAG, "onActivityResult: "+tmp);
  30. tmp = new String(str.getBytes(), "UTF-8"); Log.i(TAG, "onActivityResult: "+tmp);
  31. tmp = new String(str.getBytes(), "UTF-16"); Log.i(TAG, "onActivityResult: "+tmp);
  32. tmp = new String(str.getBytes(), "Cp1251"); Log.i(TAG, "onActivityResult: "+tmp);
  33. tmp = new String(str.getBytes(), "Cp866"); Log.i(TAG, "onActivityResult: "+tmp);
  34.  
  35. Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
  36. }
  37. //Toast.makeText(context, "Загружено "+i+" товаров", Toast.LENGTH_SHORT).show();
  38. } catch (FileNotFoundException e) {
  39. e.printStackTrace();
  40. } catch (IOException e) {
  41. e.printStackTrace();
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement