Skip to content
New issue

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

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

Already on GitHub? # to your account

Optional charset for SpssInputStream #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/com/bedatadriven/spss/SpssDataFileReader.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 BeDataDriven Groep BV
* Copyright 2017-2019 BeDataDriven Groep BV
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -86,7 +86,7 @@ public SpssDataFileReader(InputStream input) throws IOException {
this(new SpssInputStream(input));
}

private SpssDataFileReader(SpssInputStream inStream) throws IOException {
public SpssDataFileReader(SpssInputStream inStream) throws IOException {
inputStream = inStream;

String fileType = new String(inputStream.readBytes(4));
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/com/bedatadriven/spss/SpssInputStream.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017 BeDataDriven Groep BV
* Copyright 2017-2019 BeDataDriven Groep BV
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
Expand All @@ -19,13 +19,18 @@
import java.io.InputStream;
import java.nio.charset.Charset;

class SpssInputStream {
public class SpssInputStream {
private DataInputStream file;
private boolean needToFlipBytes;
private Charset charset = Charset.forName("Cp1252");
private final Charset charset;

public SpssInputStream(InputStream is, Charset charset) {
this.file = new DataInputStream(is);
this.charset = charset;
}

public SpssInputStream(InputStream is) {
file = new DataInputStream(is);
this(is, Charset.forName("Cp1252"));
}

public DataInputStream getFile() {
Expand Down