JPad
Snippets
Download
Help
Contact
JPad Write to CSV File
Writes objects to CSV using the JPad object to table converter.
Code
final File file = new File("c:\\temp\\outt.csv"); Object o = new int[] {1,2,3}; JPad.writeCsv(o, file); // read file back to check what was written Dump(Files.readAllLines(file.toPath()));
Result
Console
[int[], 1, 2, 3]
Bytecode
Compiled from "RunnContainer.java" public class io.jpad.scratch.RunnContainer { public io.jpad.scratch.RunnContainer(); Code: 0: aload_0 1: invokespecial #1 // Method java/lang/Object."<init>":()V 4: return public static void main(java.lang.String...) throws java.lang.Exception; Code: 0: new #2 // class java/io/File 3: dup 4: ldc #3 // String c:\temp\outt.csv 6: invokespecial #4 // Method java/io/File."<init>":(Ljava/lang/String;)V 9: astore_1 10: iconst_3 11: newarray int 13: dup 14: iconst_0 15: iconst_1 16: iastore 17: dup 18: iconst_1 19: iconst_2 20: iastore 21: dup 22: iconst_2 23: iconst_3 24: iastore 25: astore_2 26: aload_2 27: aload_1 28: invokestatic #5 // Method io/jpad/scratch/JPad.writeCsv:(Ljava/lang/Object;Ljava/io/File;)V 31: aload_1 32: invokevirtual #6 // Method java/io/File.toPath:()Ljava/nio/file/Path; 35: invokestatic #7 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;)Ljava/util/List; 38: invokestatic #8 // Method io/jpad/scratch/Dumper.Dump:(Ljava/lang/Object;)Ljava/lang/Object; 41: pop 42: return }
Jpad Version:1.06
viewCount:3715
Creator:
admin
Latest Editor:
admin
Tags
jpad
csv
Download
Copy As Markdown:
**code [JPad Write to CSV File.java](/example/1B/jpad-write-to-csv-file)** final File file = new File("c:\\temp\\outt.csv"); Object o = new int[] {1,2,3}; JPad.writeCsv(o, file); // read file back to check what was written Dump(Files.readAllLines(file.toPath())); **Result:** [int[], 1, 2, 3]