Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CsvWriter "No such a method" #3

Closed
justmaaarco opened this issue Jan 28, 2018 · 5 comments
Closed

CsvWriter "No such a method" #3

justmaaarco opened this issue Jan 28, 2018 · 5 comments

Comments

@justmaaarco
Copy link

I think that I found a bug inside the class CsvWriter:

"Caused by: java.lang.NoSuchMethodError: No virtual method toPath()Ljava/nio/file/Path; in class Ljava/io/File; or its super classes (declaration of 'java.io.File' appears in /system/framework/core-oj.jar)
                                                                             at de.siegmar.fastcsv.writer.CsvWriter.append(CsvWriter.java:148)"

I doesn't work on android 7.0 but it works on android 8.0, same phone.
I already tried forcing Android Studio working with Java VERSION_1_8 and VERSION_1_7 but it's still the same.

@osiegmar
Copy link
Owner

That's odd. The method java.io.File#toPath is part of the Java 7 api (see Java 7 doc). But in android-land, this method is available only since API 26 (see Android doc) -- which is indeed Android 8.0.

As I do not have any android devices to test, I do not plan to add explicit support for it.

But you could try to use the method de.siegmar.fastcsv.writer.CsvWriter#append(java.io.Writer) and pass a java.io.FileWriter instance.

@justmaaarco
Copy link
Author

I can confirm that using a FileWriter solved the issues.
Thank you very much!

@osiegmar osiegmar closed this as completed Feb 3, 2018
@joshualyon
Copy link

@osiegmar this also seems to impact the CsvReader.parse() methods where a File or Path are passed in.

And from what I can tell Objects.requireNonNull() was also only added in API 19 (Android 4.4) whereas many devs support back to API 14.

If you change your mind about supporting Android devices, Google makes virtual devices available via the Android Emulator.

@androidovshchik
Copy link

@osiegmar this also seems to impact the CsvReader.parse() methods where a File or Path are passed in.

And from what I can tell Objects.requireNonNull() was also only added in API 19 (Android 4.4) whereas many devs support back to API 14.

If you change your mind about supporting Android devices, Google makes virtual devices available via the Android Emulator.

Kotlin solution

val csvReader = CsvReader()
                    csvReader.setFieldSeparator(';')
                    csvReader.parse(BufferedReader(FileReader(path))).use { csvParser ->
                        while (true) {
                            val row = csvParser.nextRow() ?: break
                            println("Read line: $row")
                        }
                    }

@davrukin
Copy link

davrukin commented Jul 2, 2019

I also fixed this by replacing FileUtils.deleteDirectory() with File.deleteRecursively().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants