add: http.postMultipart

This commit is contained in:
hyb1996
2017-12-05 17:59:42 +08:00
parent 0473dfbf60
commit e9346f0794
11 changed files with 167 additions and 11 deletions

View File

@@ -0,0 +1,9 @@
package com.stardust.pio;
/**
* Created by Stardust on 2017/12/5.
*/
public interface PFileInterface {
String getPath();
}

View File

@@ -31,7 +31,7 @@ public class PFiles {
static final int DEFAULT_BUFFER_SIZE = 8192;
static final String DEFAULT_ENCODING = Charset.defaultCharset().name();
public static Object open(String path, String mode, String encoding, int bufferSize) {
public static PFileInterface open(String path, String mode, String encoding, int bufferSize) {
switch (mode) {
case "r":
return new PReadableTextFile(path, encoding, bufferSize);

View File

@@ -8,12 +8,13 @@ import java.util.List;
* Created by Stardust on 2017/4/1.
*/
public class PReadableTextFile implements Closeable {
public class PReadableTextFile implements Closeable, PFileInterface {
private BufferedReader mBufferedReader;
private FileInputStream mFileInputStream;
private int mBufferingSize;
private String mEncoding;
private String mPath;
public PReadableTextFile(String path) {
this(path, PFiles.DEFAULT_ENCODING);
@@ -26,6 +27,7 @@ public class PReadableTextFile implements Closeable {
public PReadableTextFile(String path, String encoding, int bufferingSize) {
mEncoding = encoding;
mBufferingSize = bufferingSize;
mPath = path;
try {
mFileInputStream = new FileInputStream(path);
} catch (FileNotFoundException e) {
@@ -103,4 +105,9 @@ public class PReadableTextFile implements Closeable {
throw new UncheckedIOException(e);
}
}
@Override
public String getPath() {
return mPath;
}
}

View File

@@ -16,7 +16,7 @@ import static com.stardust.pio.PFiles.DEFAULT_BUFFER_SIZE;
* Created by Stardust on 2017/4/1.
*/
public class PWritableTextFile implements Closeable {
public class PWritableTextFile implements Closeable, PFileInterface {
public static PWritableTextFile open(String path, String encoding, int bufferSize) {
return new PWritableTextFile(path, encoding, bufferSize, false);
@@ -35,8 +35,10 @@ public class PWritableTextFile implements Closeable {
}
private BufferedWriter mBufferedWriter;
private String mPath;
public PWritableTextFile(String path, String encoding, int bufferingSize, boolean append) {
mPath = path;
if (bufferingSize <= 0) {
bufferingSize = DEFAULT_BUFFER_SIZE;
}
@@ -116,4 +118,8 @@ public class PWritableTextFile implements Closeable {
}
@Override
public String getPath() {
return mPath;
}
}